Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky test: slice comparison to ignore element order #661

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stats/statsd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net"
"reflect"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -421,6 +422,10 @@ func TestStatsdRegisterCollector(t *testing.T) {
if len(received) != len(expected) {
return false
}

sort.Strings(received)
sort.Strings(expected)

Comment on lines +425 to +428
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried this?

Suggested change
sort.Strings(received)
sort.Strings(expected)
require.ElementsMatch(t, received, expected)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry didn't realize we're inside a require.Eventually so we can't use another require 👍

return reflect.DeepEqual(received, expected)
}, 10*time.Second, time.Millisecond)
}
Expand Down
Loading