Documentation
¶
Overview ¶
Package events records explicitly selected production event listeners. It never replaces global dispatch or changes transaction/after-commit timing.
Index ¶
- Constants
- func AssertCount[E any](t testing.TB, recorder *Recorder[E], want int)
- func AssertDispatched[E any](t testing.TB, fake *Fake, topic events.Topic[E], match func(E) bool)
- func AssertDispatchedCount[E any](t testing.TB, fake *Fake, topic events.Topic[E], match func(E) bool, want int)
- func AssertNotDispatched[E any](t testing.TB, fake *Fake, topic events.Topic[E], match func(E) bool)
- func Dispatched[E any](t testing.TB, fake *Fake, topic events.Topic[E]) []E
- func Start(t testing.TB, declarations ...events.Declaration) *events.Bus
- type Fake
- type Recorder
Constants ¶
const MaxEvents = 10000
const MaxRecordedBytes = 16 << 20
Variables ¶
This section is empty.
Functions ¶
func AssertCount ¶
AssertCount reports a test error when the recorded event count differs from want.
func AssertDispatched ¶
AssertDispatched requires at least one dispatch of topic whose payload satisfies match (nil matches any). Failure text never includes payloads.
func AssertDispatchedCount ¶
func AssertDispatchedCount[E any](t testing.TB, fake *Fake, topic events.Topic[E], match func(E) bool, want int)
AssertDispatchedCount requires exactly want dispatches of topic satisfying match.
func AssertNotDispatched ¶
func AssertNotDispatched[E any](t testing.TB, fake *Fake, topic events.Topic[E], match func(E) bool)
AssertNotDispatched requires that no dispatch of topic satisfies match.
func Dispatched ¶
Dispatched decodes every recorded payload of topic in dispatch order.
Types ¶
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake intercepts every dispatch on one production bus for the rest of the test: listeners (sync and queued) do not run, and payload snapshots are recorded for typed assertions. Dispatch still validates and captures the payload exactly as in production. Cleanup restores the bus.
type Recorder ¶
type Recorder[E any] struct { // contains filtered or unexported fields }
Recorder stores immutable typed payload snapshots in arrival order. The returned listener can coexist with real listeners in the ordinary registry. A dispatch failure does not undo earlier listener observations; use the production Topic.AfterCommit boundary when recording requires committed work.
func (*Recorder[E]) Count ¶
Count returns the synchronized payload count; a nil recorder returns zero.