From 70798ce1dfbab60ab645cf6f848c7e47c24724ec Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sat, 17 Oct 2020 13:45:52 +0200 Subject: [PATCH] Test client count --- stream/messaging_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stream/messaging_test.go b/stream/messaging_test.go index b2845e2..f7141b2 100644 --- a/stream/messaging_test.go +++ b/stream/messaging_test.go @@ -16,7 +16,7 @@ func TestWithOneOutput(t *testing.T) { // Register one output output := make(chan []byte, 64) - stream.Register(output) + stream.Register(output, false) // Try to pass one message stream.Broadcast <- []byte("hello world") @@ -25,6 +25,16 @@ func TestWithOneOutput(t *testing.T) { t.Errorf("Message has wrong content: %s != hello world", msg) } + // Check client count + if count := stream.Count(); count != 1 { + t.Errorf("Client counter returned %d, expected 1", count) + } + // Unregister - stream.Unregister(output) + stream.Unregister(output, false) + + // Check client count + if count := stream.Count(); count != 0 { + t.Errorf("Client counter returned %d, expected 0", count) + } }