Fix flaky test by using slice for stable iteration
There are no commits yet
Push commits to the source branch or add previously merged commits to review them.
Created by: mrnugget
I don't know what changed but before this fix I could pretty reliably get TestBestWorkspaceCreator
to fail by running:
go test -run TestBestWorkspaceCreator/different_user -count=10 ./internal/campaigns
It would fail with
--- FAIL: TestBestWorkspaceCreator (0.01s)
--- FAIL: TestBestWorkspaceCreator/different_user (0.01s)
expect.go:64: unexpected command: 1 error occurred:
* unexpected argument at position 4: have="bar" want="foo"
expect.go:108: unexpected number of commands executed: have=1 want=4
FAIL
FAIL github.com/sourcegraph/src-cli/internal/campaigns 0.536s
FAIL
With the fix here I can't get it to fail anymore, so I'm 99.9% sure that the error was due to range
over map
not being stable and sometimes setting up the wrong assertions which would then fail.
Push commits to the source branch or add previously merged commits to review them.