package api import "testing" func TestEventHubCapsConnectionsPerPlayerAndReleasesCapacity(t *testing.T) { hub := newEventHub() first := hub.subscribe("player-1") second := hub.subscribe("player-1") if first == nil || second == nil { t.Fatal("connection within per-player cap was rejected") } if third := hub.subscribe("player-1"); third != nil { t.Fatal("connection over per-player cap was accepted") } hub.unsubscribe(first) if third := hub.subscribe("player-1"); third == nil { t.Fatal("released connection capacity was not reusable") } else { hub.unsubscribe(third) } hub.unsubscribe(second) }