From a8c57aaeac22312f208e4079f6fa6b7d801e87a0 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 3 Jun 2026 23:08:05 -0400 Subject: [PATCH] test: assert no side effects for unknown OK in EventPublisher --- publish_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/publish_test.go b/publish_test.go index 4c60610..ce6e5a5 100644 --- a/publish_test.go +++ b/publish_test.go @@ -449,7 +449,8 @@ func TestEventPublisher(t *testing.T) { }) t.Run("unknown OK ignored", func(t *testing.T) { - p, envoy := newMockEnvoy(t) + obs := &mockObserver{} + p, envoy := newMockEnvoy(t, WithEmbassyObserver(obs)) p.connect() pub := NewEventPublisher(envoy) @@ -457,7 +458,15 @@ func TestEventPublisher(t *testing.T) { p.receive([]byte(envelope.EncloseOK("no-such-id", true, ""))) - // no panic and no side effects — confirmed by the test completing cleanly - Never(t, func() bool { return false }, "should never trigger") + Never(t, func() bool { + pub.mu.Lock() + pendingLen := len(pub.pending) + pub.mu.Unlock() + return pendingLen > 0 || + len(EventsOf[PublishAccepted](obs)) > 0 || + len(EventsOf[PublishRejected](obs)) > 0 || + len(EventsOf[PublishTimeout](obs)) > 0 || + len(EventsOf[PublishSendFailed](obs)) > 0 + }, "unknown OK should produce no side effects") }) }