mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-15 02:43:09 -06:00
Make the slice comparisons sturdy
This commit is contained in:
parent
58996fb131
commit
6fb950de86
|
|
@ -13,10 +13,10 @@
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
const longInterval = time.Hour
|
const longInterval = time.Hour
|
||||||
|
|
@ -71,9 +71,7 @@ func testGetTypingUsers(t *testing.T, tCache *TypingCache) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
gotUsers := tCache.GetTypingUsers(tt.roomID)
|
gotUsers := tCache.GetTypingUsers(tt.roomID)
|
||||||
sort.Strings(gotUsers)
|
if !test.UnsortedStringSliceEqual(gotUsers, tt.wantUsers) {
|
||||||
sort.Strings(tt.wantUsers)
|
|
||||||
if !reflect.DeepEqual(gotUsers, tt.wantUsers) {
|
|
||||||
t.Errorf("TypingCache.GetTypingUsers(%s) = %v, want %v", tt.roomID, gotUsers, tt.wantUsers)
|
t.Errorf("TypingCache.GetTypingUsers(%s) = %v, want %v", tt.roomID, gotUsers, tt.wantUsers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +88,7 @@ func testRemoveUserIfExpired(t *testing.T, tCache *TypingCache) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tCache.removeUserIfExpired(tt.userID, tt.roomID)
|
tCache.removeUserIfExpired(tt.userID, tt.roomID)
|
||||||
if gotUsers := tCache.GetTypingUsers(tt.roomID); !reflect.DeepEqual(gotUsers, tt.wantUsers) {
|
if gotUsers := tCache.GetTypingUsers(tt.roomID); !test.UnsortedStringSliceEqual(gotUsers, tt.wantUsers) {
|
||||||
t.Errorf("TypingCache.GetTypingUsers(%s) = %v, want %v", tt.roomID, gotUsers, tt.wantUsers)
|
t.Errorf("TypingCache.GetTypingUsers(%s) = %v, want %v", tt.roomID, gotUsers, tt.wantUsers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue