test: NoticeHandler observer notified

This commit is contained in:
Jay
2026-06-03 15:19:42 -04:00
parent 9d4873f8d4
commit cf4a2d380a
2 changed files with 17 additions and 4 deletions
+11 -3
View File
@@ -48,9 +48,17 @@ func TestNoticeHandler(t *testing.T) {
})
t.Run("observer notified", func(t *testing.T) {
// wire mockObserver via envoy (requires constructor option or mock envoy)
// p.receive(envelope.EncloseNotice("hello"))
// Eventually: mockObserver recorded NoticeReceived{Message: "hello"}
obs := &mockObserver{}
p, envoy := newMockEnvoy(t, WithEmbassyObserver(obs))
h := NewNoticeHandler(envoy)
t.Cleanup(h.Close)
p.receive([]byte(envelope.EncloseNotice("hello")))
Eventually(t, func() bool {
events := EventsOf[NoticeReceived](obs)
return len(events) == 1 && events[0].Message == "hello"
}, "NoticeReceived observable not recorded")
})
t.Run("close cleans up", func(t *testing.T) {