fix: sort slices before comparing in test #142
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The Runner test
TestRunner_GetBaseActionCfg/extraEnv_adds_and_overrides_defaults
insrc/pkg/runner/actions_test.go
is flaky because we don't sort the string slices before comparing them, and occasionally they get created in slightly different orders:note the expected
"ENV2=alsoFromEnv", "ENV3=fromExtra"
vs. the actual"ENV3=fromExtra", "ENV2=alsoFromEnv"
.Assuming a successful test run produces this output:
If we run the test enough times it will fail, as shown below where we would expect 200 lines of
-- PASS
here when running the test 100 times (2x per run), and 0 for--- FAIL
:It's flaky, so your numbers will vary each time you run it.
In this PR we sort both slices before comparing.
Here's the updated output:
Type of change
Checklist before merging