1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 20:52:20 +00:00

Test client count

This commit is contained in:
Alexandre Iooss 2020-10-17 13:45:52 +02:00
parent 5b8c73057b
commit 70798ce1df
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02

View File

@ -16,7 +16,7 @@ func TestWithOneOutput(t *testing.T) {
// Register one output // Register one output
output := make(chan []byte, 64) output := make(chan []byte, 64)
stream.Register(output) stream.Register(output, false)
// Try to pass one message // Try to pass one message
stream.Broadcast <- []byte("hello world") stream.Broadcast <- []byte("hello world")
@ -25,6 +25,16 @@ func TestWithOneOutput(t *testing.T) {
t.Errorf("Message has wrong content: %s != hello world", msg) 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 // 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)
}
} }