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

Use ElementsMatch to ignore order #190

Merged
merged 2 commits into from
May 24, 2023
Merged

Conversation

kevinv-stripe
Copy link
Contributor

@kevinv-stripe kevinv-stripe commented May 24, 2023

Fixes a non-deterministic failing test TestMapKeys.

This change switches the test comparison to require.ElementsMatch to compare slices, which ignores ordering, since iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next.

https://go.dev/ref/spec#For_statements

Verified that consecutive tests now pass:

➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.169s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.152s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.160s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.156s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.159s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.141s
➜  smokescreen git:(kevinv/fix-test-map-keys) ✗ go test ./pkg/smokescreen/metrics/... -count=1
ok  	github.com/stripe/smokescreen/pkg/smokescreen/metrics	0.159s

@github-actions
Copy link

github-actions bot commented May 24, 2023

Pull Request Test Coverage Report for Build 5073174494

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 62.512%

Totals Coverage Status
Change from base Build 5024495973: 0.0%
Covered Lines: 1294
Relevant Lines: 2070

💛 - Coveralls

@kevinv-stripe kevinv-stripe merged commit c227b0d into master May 24, 2023
@kevinv-stripe kevinv-stripe deleted the kevinv/fix-test-map-keys branch May 24, 2023 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants