eventbustest

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package eventbustest tests event bus implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Basic

func Basic(t *testing.T, newBus EventBusFactory, opts ...Option)

Basic tests the basic functionality of an event bus. The test is successful if multiple subscribers of the same event receive the event when it is published.

func CancelSubscription

func CancelSubscription(t *testing.T, newBus EventBusFactory, opts ...Option)

func PublishMultipleEvents

func PublishMultipleEvents(t *testing.T, newBus EventBusFactory, opts ...Option)

func RunCore added in v0.1.2

func RunCore(t *testing.T, newBus EventBusFactory, opts ...Option)

RunCore tests all functions of the event bus.

func RunWildcard added in v0.1.2

func RunWildcard(t *testing.T, newBus EventBusFactory, opts ...Option)

func SubscribeCanceledContext

func SubscribeCanceledContext(t *testing.T, newBus EventBusFactory, opts ...Option)

func SubscribeMultipleEvents

func SubscribeMultipleEvents(t *testing.T, newBus EventBusFactory, opts ...Option)

Types

type EventBusFactory

type EventBusFactory func(codec.Encoding) event.Bus

EventBusFactory creates an event.Bus from an codec.Encoding.

type Expectations

type Expectations struct {
	// contains filtered or unexported fields
}

func Expect

func Expect(ctx context.Context) *Expectations

Expect returns a new Expectation for expecting subscribed events and errors.

func (*Expectations) Apply

func (ex *Expectations) Apply(t *testing.T)

Apply applies the result to the provided test. If the result is an error, t.Fatal(err) is called.

func (*Expectations) Closed

func (ex *Expectations) Closed(sub Subscription, timeout time.Duration)

Closed expects the event and error channels of a subscription to be closed within the given duration.

func (*Expectations) Event

func (ex *Expectations) Event(sub Subscription, timeout time.Duration, names ...string)

Event expects any of the given events to be received within the given duration.

func (*Expectations) Events

func (ex *Expectations) Events(sub Subscription, timeout time.Duration, names ...string)

Events expects all of the given events to be received within the given duration.

func (*Expectations) Nothing

func (ex *Expectations) Nothing(sub Subscription, timeout time.Duration)

Nothing expectes that nothing happens to the event and error channel of a subscription within the given duration.

func (*Expectations) Result

func (ex *Expectations) Result() error

Result returns the result of the expectations.

type Option added in v0.1.2

type Option func(*config)

func Cleanup added in v0.1.2

func Cleanup[Bus event.Bus](cleanup func(Bus) error) Option

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

A Subscription wraps the event and and error channels from an event subscription

func MustSub

func MustSub(events <-chan event.Event, errs <-chan error, err error) Subscription

MustSub does the same as Sub, but accepts an additional error argument so it can be used like this:

var bus event.Bus
sub := MustSub(bus.Subscribe(context.TODO(), "foo"))

MustSub panics if error is not nil.

func Sub

func Sub(events <-chan event.Event, errs <-chan error) Subscription

Sub wraps the given event and error channels in a Subscription.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL