Documentation ¶
Overview ¶
Package eventbustest tests event bus implementations.
Index ¶
- func Basic(t *testing.T, newBus EventBusFactory, opts ...Option)
- func CancelSubscription(t *testing.T, newBus EventBusFactory, opts ...Option)
- func PublishMultipleEvents(t *testing.T, newBus EventBusFactory, opts ...Option)
- func RunCore(t *testing.T, newBus EventBusFactory, opts ...Option)
- func RunWildcard(t *testing.T, newBus EventBusFactory, opts ...Option)
- func SubscribeCanceledContext(t *testing.T, newBus EventBusFactory, opts ...Option)
- func SubscribeMultipleEvents(t *testing.T, newBus EventBusFactory, opts ...Option)
- type EventBusFactory
- type Expectations
- func (ex *Expectations) Apply(t *testing.T)
- func (ex *Expectations) Closed(sub Subscription, timeout time.Duration)
- func (ex *Expectations) Event(sub Subscription, timeout time.Duration, names ...string)
- func (ex *Expectations) Events(sub Subscription, timeout time.Duration, names ...string)
- func (ex *Expectations) Nothing(sub Subscription, timeout time.Duration)
- func (ex *Expectations) Result() error
- type Option
- type Subscription
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 ¶
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 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.