Skip to content

Commit cef132c

Browse files
committed
test: fix flaky Participants tests
1 parent d80378a commit cef132c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

game_state_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ func TestParticipants_All(t *testing.T) {
5959

6060
allPlayers := gs.Participants().All()
6161

62-
assert.Len(t, allPlayers, 1)
63-
assert.Equal(t, pl, allPlayers[0])
62+
assert.ElementsMatch(t, []*common.Player{pl}, allPlayers)
6463
}
6564

6665
func TestParticipants_Playing(t *testing.T) {
@@ -84,8 +83,7 @@ func TestParticipants_Playing(t *testing.T) {
8483
playing := gs.Participants().Playing()
8584

8685
assert.Len(t, playing, 2)
87-
assert.Equal(t, terrorist, playing[0])
88-
assert.Equal(t, ct, playing[1])
86+
assert.ElementsMatch(t, []*common.Player{terrorist, ct}, playing)
8987
}
9088

9189
func TestParticipants_TeamMembers(t *testing.T) {
@@ -106,10 +104,9 @@ func TestParticipants_TeamMembers(t *testing.T) {
106104
def := common.NewPlayer()
107105
gs.playersByUserID[4] = def
108106

109-
playing := gs.Participants().TeamMembers(common.TeamCounterTerrorists)
107+
cts := gs.Participants().TeamMembers(common.TeamCounterTerrorists)
110108

111-
assert.Len(t, playing, 1)
112-
assert.Equal(t, ct, playing[0])
109+
assert.ElementsMatch(t, []*common.Player{ct}, cts)
113110
}
114111

115112
func TestParticipants_FindByHandle(t *testing.T) {

0 commit comments

Comments
 (0)