diff --git a/src/github.com/matrix-org/dendrite/typingserver/cache/cache_test.go b/src/github.com/matrix-org/dendrite/typingserver/cache/cache_test.go index 85a447707..92baebafb 100644 --- a/src/github.com/matrix-org/dendrite/typingserver/cache/cache_test.go +++ b/src/github.com/matrix-org/dendrite/typingserver/cache/cache_test.go @@ -13,7 +13,6 @@ package cache import ( - "math/rand" "testing" "time" @@ -84,17 +83,17 @@ func testRemoveUser(t *testing.T, tCache *TypingCache) { {"room3", []string{"user1"}}, {"room4", []string{"user1", "user2", "user3"}}, } + for _, tt := range tests { for _, userID := range tt.userIDs { tCache.AddTypingUser(userID, tt.roomID, nil) } - i := rand.Intn(len(tt.userIDs)) - tCache.removeUser(tt.userIDs[i], tt.roomID) - expLeftUsers := append(tt.userIDs[:i], tt.userIDs[i+1:]...) + length := len(tt.userIDs) + tCache.removeUser(tt.userIDs[length-1], tt.roomID) + expLeftUsers := tt.userIDs[:length-1] if leftUsers := tCache.GetTypingUsers(tt.roomID); !test.UnsortedStringSliceEqual(leftUsers, expLeftUsers) { - t.Errorf("Response after removal is unexpected %s/%s", leftUsers, expLeftUsers) + t.Errorf("Response after removal is unexpected. Want = %s, got = %s", leftUsers, expLeftUsers) } } - }