From 163408da5f9ae44f74753e9abb95aa7aaafeb1ce Mon Sep 17 00:00:00 2001 From: Leonidas Vrachnis Date: Thu, 26 Sep 2024 21:28:49 +0200 Subject: [PATCH] fix: flaky test: slice comparison to ignore element order --- stats/statsd_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stats/statsd_test.go b/stats/statsd_test.go index 19a9e3f9..00a1fa4d 100644 --- a/stats/statsd_test.go +++ b/stats/statsd_test.go @@ -6,6 +6,7 @@ import ( "io" "net" "reflect" + "sort" "strconv" "strings" "sync" @@ -421,6 +422,10 @@ func TestStatsdRegisterCollector(t *testing.T) { if len(received) != len(expected) { return false } + + sort.Strings(received) + sort.Strings(expected) + return reflect.DeepEqual(received, expected) }, 10*time.Second, time.Millisecond) }