Test server's client map

This commit is contained in:
Derek Collison
2012-12-18 17:27:03 -08:00
parent ec9c016464
commit 69bc1a2e25

View File

@@ -11,6 +11,7 @@ import (
"regexp"
"strings"
"testing"
"time"
)
type serverInfo struct {
@@ -375,3 +376,17 @@ func TestClientRemoveSubsOnDisconnect(t *testing.T) {
t.Fatalf("Should have no subscriptions after close, got %d\n", s.sl.Count())
}
}
func TestClientMapRemoval(t *testing.T) {
s, c, _ := setupClient()
c.conn.Close()
end := time.Now().Add(1 * time.Second)
for time.Now().Before(end) {
if len(s.clients) > 0 {
time.Sleep(5 * time.Millisecond)
}
}
if len(s.clients) > 0 {
t.Fatal("Client still in server map")
}
}