InMemoryTestTransport
A Transport that records every event in memory instead of sending it anywhere — for unit tests that need to assert "does this code fire the right event with the right properties?" without a real backend or dev.ynagai.autograph.DebugTransport's log-only, non-assertable output.
val transport = InMemoryTestTransport()
val tracker = Autograph {
transport(transport)
store = InMemorySeqStore() // don't let seq/session state leak onto disk between test runs
dispatcher = kotlinx.coroutines.Dispatchers.Unconfined // stamp synchronously in tests
}
tracker.track("Recipe Saved", target = "share_button")
transport.assertEventFired("Recipe Saved", properties = mapOf("target" to "share_button"))Types
One recorded call. name is the event/screen name for Kind.TRACK/Kind.SCREEN, or the user id for Kind.IDENTIFY.
Properties
Functions
Asserts that a track event named name was recorded, and returns it.
Asserts that no track event named name was ever recorded.
Asserts that identify(userId, ...) was recorded, and returns it. See assertEventFired for traits/exact.
Asserts that both dev.ynagai.autograph.Envelope.seq (gapless, +1 within each contiguous run of events sharing a session id — a session rotation restarts it at 1, which is expected and not a gap) and dev.ynagai.autograph.Envelope.globalSeq (gapless, +1 across the whole device lifetime, independent of session) hold wherever each is non-null. Depending on AutographConfig.sequence, only one, both, or neither may be stamped (SequenceMode.None stamps neither, so nothing is checked); events with no envelope are skipped.
Asserts that events fired in exactly this names order (across all kinds — track/screen/identify).
Asserts that a screen event named name was recorded, and returns it. See assertEventFired for properties/exact.
Asserts every recorded event with an envelope belongs to the same session (no rotation occurred), and returns that session id.