mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
23 lines
619 B
Go
23 lines
619 B
Go
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)
|
|
}
|