[#5793] added subscriptions.Broker.TotalClients() method

This commit is contained in:
Gani Georgiev
2024-11-04 19:16:25 +02:00
parent f9a2d6c6ae
commit 755149c915
3 changed files with 22 additions and 0 deletions

View File

@@ -62,6 +62,21 @@ func TestChunkedClients(t *testing.T) {
}
}
func TestTotalClients(t *testing.T) {
b := subscriptions.NewBroker()
if total := b.TotalClients(); total != 0 {
t.Fatalf("Expected no clients, got %d", total)
}
b.Register(subscriptions.NewDefaultClient())
b.Register(subscriptions.NewDefaultClient())
if total := b.TotalClients(); total != 2 {
t.Fatalf("Expected %d clients, got %d", 2, total)
}
}
func TestClientById(t *testing.T) {
b := subscriptions.NewBroker()