From 95b22386a69fa7e3d05d1e3bfaf6f6839a6c6641 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Thu, 2 Apr 2020 07:17:32 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=20=D0=BD=D0=B0=20=D0=BF=D1=83=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8E=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2=202=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BD=D1=8B=D1=85=20=D1=82=D0=BE=D0=BF=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pubsub/pubsub_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index 94d3227..07a8811 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -65,6 +65,32 @@ func TestPubSub_nonBlockPublish(t *testing.T) { } } +func TestPubSub_multipleSubjects(t *testing.T) { + p := NewPubSub() + defer checkedClose(t, p) + + wg := sync.WaitGroup{} + wg.Add(2) + + _, err := p.Subscribe("sub1", func(msg interface{}) { + require.Equal(t, "blah-blah-1", msg) + wg.Done() + }) + require.NoError(t, err) + + _, err = p.Subscribe("sub2", func(msg interface{}) { + require.Equal(t, "blah-blah-2", msg) + wg.Done() + }) + require.NoError(t, err) + + err = p.Publish("sub1", "blah-blah-1") + err = p.Publish("sub2", "blah-blah-2") + require.NoError(t, err) + + wg.Wait() +} + func TestPubSub_multipleSubscribers(t *testing.T) { p := NewPubSub() defer checkedClose(t, p)