mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 01:43:09 -06:00
Write deterministic test
This commit is contained in:
parent
738f014fcb
commit
15f451bbc1
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue