From fcdf106ce130e231840186028a9ee1d441f0c869 Mon Sep 17 00:00:00 2001 From: Peter Csajtai Date: Wed, 30 Oct 2024 15:55:38 +0100 Subject: [PATCH] Update publisher_test.go --- pubsub/publisher_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pubsub/publisher_test.go b/pubsub/publisher_test.go index ede4dca..693501b 100644 --- a/pubsub/publisher_test.go +++ b/pubsub/publisher_test.go @@ -12,8 +12,10 @@ func TestPubSub_Sub_Unsub(t *testing.T) { sub := make(chan struct{}) pubSub.Subscribe(sub) - assert.NotEmpty(t, pubSub.subscriptions) - assert.NotNil(t, pubSub.subscriptions[sub]) + utils.WaitUntil(2*time.Second, func() bool { + _, ok := pubSub.subscriptions[sub] + return ok + }) msg := struct{}{} pubSub.Publish(msg) @@ -28,5 +30,6 @@ func TestPubSub_Sub_Unsub(t *testing.T) { pubSub.Close() sub2 := make(chan struct{}) pubSub.Subscribe(sub2) - assert.Empty(t, pubSub.subscriptions) + _, ok := pubSub.subscriptions[sub2] + assert.False(t, ok) }