package main import ( "context" "testing" "github.com/nats-io/nats.go" "github.com/nats-io/nats.go/jetstream" "git.novox.be/novox/mesh-sdk/go/process" ) type recordingPublisher struct{ msgs []*nats.Msg } func (r *recordingPublisher) PublishMsg(_ context.Context, m *nats.Msg, _ ...jetstream.PublishOpt) (*jetstream.PubAck, error) { r.msgs = append(r.msgs, m) return &jetstream.PubAck{}, nil } // A-41, review finding 1: the keeper publishes on the subject the module's events stream captures. func TestTheKeeperPublishesOnTheEventsStreamsSubject(t *testing.T) { p := &recordingPublisher{} acct := process.Account{Node: "n1", Module: "zfs"} if err := publishEvent(p, acct, EventApplied, map[string]string{"key": "x"}); err != nil { t.Fatal(err) } if len(p.msgs) != 1 || p.msgs[0].Subject != "mesh.bus.zfs.events."+EventApplied || p.msgs[0].Header.Get("x-event-id") == "" { t.Errorf("%+v", p.msgs) } }