Merge pull request #3641 from photra/3636-deflake-testvolumecreateclusteropts

Deflake TestVolumeCreateClusterOpts
This commit is contained in:
Sebastiaan van Stijn 2022-06-03 12:08:47 +02:00 committed by GitHub
commit 9cda6ce011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package volume
import ( import (
"context" "context"
"fmt" "fmt"
"sort"
"strings" "strings"
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
@ -153,6 +154,9 @@ func runCreate(dockerCli command.Cli, options createOptions) error {
}, },
) )
} }
sort.SliceStable(volOpts.ClusterVolumeSpec.Secrets, func(i, j int) bool {
return volOpts.ClusterVolumeSpec.Secrets[i].Key < volOpts.ClusterVolumeSpec.Secrets[j].Key
})
// TODO(dperny): ignore if no topology specified // TODO(dperny): ignore if no topology specified
topology := &volume.TopologyRequirement{} topology := &volume.TopologyRequirement{}

View File

@ -3,6 +3,7 @@ package volume
import ( import (
"io" "io"
"reflect" "reflect"
"sort"
"strings" "strings"
"testing" "testing"
@ -192,6 +193,9 @@ func TestVolumeCreateClusterOpts(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) { volumeCreateFunc: func(body volume.CreateOptions) (volume.Volume, error) {
sort.SliceStable(body.ClusterVolumeSpec.Secrets, func(i, j int) bool {
return body.ClusterVolumeSpec.Secrets[i].Key < body.ClusterVolumeSpec.Secrets[j].Key
})
assert.DeepEqual(t, body, expectedBody) assert.DeepEqual(t, body, expectedBody)
return volume.Volume{}, nil return volume.Volume{}, nil
}, },