-
Notifications
You must be signed in to change notification settings - Fork 10
/
wildcard.go
45 lines (34 loc) · 940 Bytes
/
wildcard.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package eventbustest
import (
"context"
"testing"
"time"
"github.com/modernice/goes/event"
"github.com/modernice/goes/event/test"
)
//jotbot:ignore
func RunWildcard(t *testing.T, newBus EventBusFactory, opts ...Option) {
cfg := configure(opts...)
t.Run("Wildcard", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
bus := newBus(enc)
defer cfg.Cleanup(t, bus)
str, errs, err := bus.Subscribe(ctx, event.All)
if err != nil {
t.Fatalf("subscribe to events: %v", err)
}
sub := Sub(str, errs)
ex := Expect(ctx)
ex.Events(sub, 900*time.Millisecond, "foo", "bar", "baz")
events := []event.Event{
event.New("foo", test.FooEventData{}).Any(),
event.New("bar", test.BarEventData{}).Any(),
event.New("baz", test.BazEventData{}).Any(),
}
if err := bus.Publish(ctx, events...); err != nil {
t.Fatalf("publish events: %v", err)
}
ex.Apply(t)
})
}