blob: 2976bce80a82fd0e454ad6d6f8161993136f2e77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package game
import "testing"
// TestSafespotManagerRekeyRooms: a live room rename must remap the room ID
// stored on an active safespot, or the safespot lookup misses and the player
// is force-ejected from cover.
func TestSafespotManagerRekeyRooms(t *testing.T) {
m := NewSafespotManager()
m.Set("alice", SafespotState{Active: true, ObjectDefID: "bush", RoomID: 5})
m.Set("bob", SafespotState{Active: true, ObjectDefID: "rock", RoomID: 9})
m.RekeyRooms(map[int]int{5: 7})
if ss, _ := m.Get("alice"); ss.RoomID != 7 {
t.Fatalf("alice safespot room = %d, want 7", ss.RoomID)
}
if ss, _ := m.Get("bob"); ss.RoomID != 9 {
t.Fatalf("bob safespot room = %d, want 9 (unchanged)", ss.RoomID)
}
}
|