Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertExactMatch ¶
AssertExactMatch is an assertion that checks the input slice of EventP predicate match 1 to 1 with a given list of supervision system events.
func AssertPartialMatch ¶
AssertPartialMatch is an assertion that matches in order a list of EventP predicates to a list of supervision system events.
The input events need to match in the predicate order, but the events do not need to be a one to one match (e.g. the input events slice length may be bigger than the predicates slice length).
This function is useful when we want to test that some events are present in the expected order. This is useful in test-cases where a supervision system emits an overwhelming number of events.
Types ¶
type AndP ¶
AndP is a predicate that builds the conjunction of a group EventP predicates (e.g. join EventP predicates with &&)
type EventIterator ¶
type EventIterator[A any] struct { // contains filtered or unexported fields }
EventIterator represents a single iteration over the list of events that have been collected by the EventManager that created it.
func (*EventIterator[A]) TakeTill ¶
func (ei *EventIterator[A]) TakeTill(pred EventP[A]) []A
TakeTill takes all the events that have been collected since the current index until the given predicate returns true
func (*EventIterator[A]) WaitTill ¶
func (ei *EventIterator[A]) WaitTill(pred EventP[A])
WaitTill blocks until an event from the supervision system returns true for the given predicate
type EventManager ¶
type EventManager[A any] struct { // contains filtered or unexported fields }
EventManager provides an API that allows to block a goroutine for particular events in a test system
func NewEventManager ¶
func NewEventManager[A any]() EventManager[A]
NewEventManager returns an EventManager instance that can be used to wait for events to happen on the observed supervision system
func (EventManager[A]) EventCollector ¶
func (em EventManager[A]) EventCollector(ctx context.Context) func(ev A)
EventCollector is used as an event notifier of a supervision system
func (EventManager[A]) GetEventIx ¶
func (em EventManager[A]) GetEventIx(evIx int) (A, bool)
GetEventIx returns the nth event that got emitted by a supervision system, if the given index is greater than the event buffer length, this function will wait until that index is reached. If the index is never reached, the second return value will be false.
func (EventManager[A]) Iterator ¶
func (em EventManager[A]) Iterator() EventIterator[A]
Iterator returns an iterator over the collected events. This iterator will block waiting for new events
func (EventManager[A]) Snapshot ¶
func (em EventManager[A]) Snapshot() []A
Snapshot returns all the events that this EventManager has collected from the supervision system
func (EventManager[A]) StartCollector ¶
func (em EventManager[A]) StartCollector(ctx context.Context)
StartCollector starts the goroutine that reads the evCh that gets filled by the supervision system
type EventP ¶
type EventP[A any] interface { // Call will execute the logic of this event predicate Call(A) bool // Returns an string representation of this event predicate (for debugging // purposes) String() string }
EventP represents a predicate function that allows us to assert properties of an Event signaled by the supervision system