From 284bad441191dbdea247079d4a35505d4c5e5765 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Sun, 31 Oct 2021 02:25:10 +0100 Subject: [PATCH] Avoid test flakyness by ordering volumes before checking Signed-off-by: Ulysses Souza --- pkg/compose/create_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/compose/create_test.go b/pkg/compose/create_test.go index 9046afb41..02736c0bf 100644 --- a/pkg/compose/create_test.go +++ b/pkg/compose/create_test.go @@ -19,6 +19,7 @@ package compose import ( "os" "path/filepath" + "sort" "testing" "github.com/compose-spec/compose-go/types" @@ -124,12 +125,18 @@ func TestBuildContainerMountOptions(t *testing.T) { } mounts, err := buildContainerMountOptions(project, project.Services[0], moby.ImageInspect{}, inherit) + sort.Slice(mounts, func(i, j int) bool { + return mounts[i].Target < mounts[j].Target + }) assert.NilError(t, err) assert.Assert(t, len(mounts) == 2) assert.Equal(t, mounts[0].Target, "/var/myvolume1") assert.Equal(t, mounts[1].Target, "/var/myvolume2") mounts, err = buildContainerMountOptions(project, project.Services[0], moby.ImageInspect{}, inherit) + sort.Slice(mounts, func(i, j int) bool { + return mounts[i].Target < mounts[j].Target + }) assert.NilError(t, err) assert.Assert(t, len(mounts) == 2) assert.Equal(t, mounts[0].Target, "/var/myvolume1")