From 6fb950de8602d8cc3684b2df72bb2ba3a7824c09 Mon Sep 17 00:00:00 2001 From: Anant Prakash Date: Thu, 26 Jul 2018 20:09:09 +0530 Subject: [PATCH] Make the slice comparisons sturdy --- .../dendrite/typingserver/cache/cache_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 69eae8476..6f94ea479 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,10 +13,10 @@ package cache import ( - "reflect" - "sort" "testing" "time" + + "github.com/matrix-org/dendrite/common/test" ) const longInterval = time.Hour @@ -71,9 +71,7 @@ func testGetTypingUsers(t *testing.T, tCache *TypingCache) { for _, tt := range tests { gotUsers := tCache.GetTypingUsers(tt.roomID) - sort.Strings(gotUsers) - sort.Strings(tt.wantUsers) - if !reflect.DeepEqual(gotUsers, tt.wantUsers) { + if !test.UnsortedStringSliceEqual(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 { 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) } }