Documentation
¶
Overview ¶
Package assertions provides event assertion utilities for testing event-sourced systems. It includes helpers for comparing events, checking event types, and generating event diffs.
Index ¶
- func AssertAllMatch(t TB, events []interface{}, matcher EventMatcher)
- func AssertAnyMatch(t TB, events []interface{}, matcher EventMatcher)
- func AssertContainsEvent[T any](t TB, events []interface{}, expected T)
- func AssertContainsEventType(t TB, events []interface{}, typeName string)
- func AssertEventAtIndex[T any](t TB, events []interface{}, index int, expected T)
- func AssertEventCount(t TB, events []interface{}, expected int)
- func AssertEventData[T any](t TB, event interface{}, expected T)
- func AssertEventTypes(t TB, events []interface{}, types ...string)
- func AssertEventsEqual(t TB, expected, actual []interface{})
- func AssertEventsMatch(t TB, expected, actual []interface{})
- func AssertFirstEvent[T any](t TB, events []interface{}, expected T)
- func AssertLastEvent[T any](t TB, events []interface{}, expected T)
- func AssertNoEvents(t TB, events []interface{})
- func AssertNoneMatch(t TB, events []interface{}, matcher EventMatcher)
- func CountMatches(events []interface{}, matcher EventMatcher) int
- func FilterEvents(events []interface{}, matcher EventMatcher) []interface{}
- func FormatDiffs(diffs []EventDiff) string
- type DiffType
- type EventDiff
- type EventMatcher
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAllMatch ¶
func AssertAllMatch(t TB, events []interface{}, matcher EventMatcher)
AssertAllMatch checks that all events match the matcher.
func AssertAnyMatch ¶
func AssertAnyMatch(t TB, events []interface{}, matcher EventMatcher)
AssertAnyMatch checks that at least one event matches the matcher.
func AssertContainsEvent ¶
AssertContainsEvent checks that the events contain an event of the expected type and data.
func AssertContainsEventType ¶
AssertContainsEventType checks that the events contain at least one event of the specified type.
func AssertEventAtIndex ¶
AssertEventAtIndex checks the event at a specific index matches the expected data.
func AssertEventCount ¶
AssertEventCount checks the number of events.
func AssertEventData ¶
AssertEventData checks that a specific event matches the expected data.
func AssertEventTypes ¶
AssertEventTypes checks that the events have the expected types in order.
func AssertEventsEqual ¶
func AssertEventsEqual(t TB, expected, actual []interface{})
AssertEventsEqual compares two event slices and fails if they differ.
func AssertEventsMatch ¶
func AssertEventsMatch(t TB, expected, actual []interface{})
AssertEventsMatch checks that actual events match expected events, allowing for extra events at the end.
func AssertFirstEvent ¶
AssertFirstEvent checks the first event matches the expected data.
func AssertLastEvent ¶
AssertLastEvent checks the last event matches the expected data.
func AssertNoEvents ¶
func AssertNoEvents(t TB, events []interface{})
AssertNoEvents checks that no events were produced.
func AssertNoneMatch ¶
func AssertNoneMatch(t TB, events []interface{}, matcher EventMatcher)
AssertNoneMatch checks that no events match the matcher.
func CountMatches ¶
func CountMatches(events []interface{}, matcher EventMatcher) int
CountMatches returns the number of events that match the matcher.
func FilterEvents ¶
func FilterEvents(events []interface{}, matcher EventMatcher) []interface{}
FilterEvents returns events that match the matcher.
func FormatDiffs ¶
FormatDiffs formats event diffs as a human-readable string.
Types ¶
type EventDiff ¶
EventDiff represents a difference between expected and actual events.
func DiffEvents ¶
func DiffEvents(expected, actual []interface{}) []EventDiff
DiffEvents compares two event slices and returns the differences.
type EventMatcher ¶
type EventMatcher func(event interface{}) bool
EventMatcher is a function that checks if an event matches certain criteria.
func MatchEvent ¶
func MatchEvent[T any](expected T) EventMatcher
MatchEvent returns a matcher that checks for exact event equality.
func MatchEventType ¶
func MatchEventType(typeName string) EventMatcher
MatchEventType returns a matcher that checks for a specific event type.