algolia / cli

🔍 Algolia’s official CLI devtool
https://www.algolia.com/doc/tools/cli
MIT License
103 stars 26 forks source link

test: remove flaky test due to map ordering randomness #119

Closed Nagriar closed 1 year ago

Nagriar commented 1 year ago

Summary

Fix flaky test:

    remove_test.go:149: 
            Error Trace:    /home/runner/work/cli/cli/pkg/cmd/profile/remove/remove_test.go:149
            Error:          Not equal: 
                            expected: "✓ 'foo' removed successfully.\n"
                            actual  : "✓ 'foo' removed successfully. Set a new default profile with 'algolia profile setdefault'.\n"

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,2 +1,2 @@
                            -✓ 'foo' removed successfully.
                            +✓ 'foo' removed successfully. Set a new default profile with 'algolia profile setdefault'.

            Test:           Test_runRemoveCmd/existing_profile_(non-default)

This test is flaky due to the go maps which doesn't have a predictable order and the function test.NewConfigStubWithProfiles relies on the order to define the profile used. This PR leverages a slice to have a predictable ordering