Skip to content

Fix flaky run download test #10005

@williammartin

Description

@williammartin

Description

1136764 introduced a test utility for run download tests. It is flaky because it relies on map ordering being consistent.

➜  go test -count=1 ./pkg/cmd/run/download/...

--- FAIL: Test_runDownload (0.05s)

        mock.go:227:
                Error Trace:    /Users/williammartin/go/pkg/mod/github.com/cli/go-gh/v2@v2.11.1/pkg/prompter/mock.go:227
                                                        /Users/williammartin/go/pkg/mod/github.com/cli/go-gh/v2@v2.11.1/pkg/prompter/mock.go:122
                                                        /Users/williammartin/workspace/cli/pkg/cmd/run/download/download.go:139
                                                        /Users/williammartin/workspace/cli/pkg/cmd/run/download/download_test.go:686
                Error:          Not equal:
                                expected: []string{"artifact-1", "artifact-2"}
                                actual  : []string{"artifact-2", "artifact-1"}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,4 +1,4 @@
                                 ([]string) (len=2) {
                                - (string) (len=10) "artifact-1",
                                - (string) (len=10) "artifact-2"
                                + (string) (len=10) "artifact-2",
                                + (string) (len=10) "artifact-1"

                Test:           Test_runDownload/prompt_to_select_artifact
FAIL
FAIL    github.com/cli/cli/v2/pkg/cmd/run/download      0.336s
FAIL

Evidence: https://github.com/cli/cli/actions/runs/12158754328/job/33907377186#step:5:224

Expected Output

The test is not flaky.

Metadata

Metadata

Assignees

Labels

tech-debtA chore that addresses technical debt

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions