diff --git a/daemon/cluster/executor/container/container_test.go b/daemon/cluster/executor/container/container_test.go index eebf9918b1..691f888306 100644 --- a/daemon/cluster/executor/container/container_test.go +++ b/daemon/cluster/executor/container/container_test.go @@ -210,7 +210,7 @@ func TestTmpfsConversion(t *testing.T) { }, } config := containerConfig{task: &task} - assert.Check(t, is.DeepEqual(c.to, config.hostConfig().Mounts)) + assert.Check(t, is.DeepEqual(c.to, config.hostConfig(nil).Mounts)) }) } } diff --git a/volume/mounts/linux_parser_test.go b/volume/mounts/linux_parser_test.go index d4c7a3856e..a9de82a1eb 100644 --- a/volume/mounts/linux_parser_test.go +++ b/volume/mounts/linux_parser_test.go @@ -238,6 +238,7 @@ func TestConvertTmpfsOptions(t *testing.T) { readOnly bool expectedSubstrings []string unexpectedSubstrings []string + err bool } cases := []testCase{ { @@ -252,10 +253,26 @@ func TestConvertTmpfsOptions(t *testing.T) { expectedSubstrings: []string{"ro"}, unexpectedSubstrings: []string{}, }, + { + opt: mount.TmpfsOptions{Options: "exec"}, + readOnly: true, + expectedSubstrings: []string{"ro", "exec"}, + unexpectedSubstrings: []string{"noexec"}, + }, + { + opt: mount.TmpfsOptions{Options: "INVALID"}, + err: true, + }, } p := NewLinuxParser() for _, tc := range cases { data, err := p.ConvertTmpfsOptions(&tc.opt, tc.readOnly) + if tc.err { + if err == nil { + t.Fatalf("expected error for %+v, got nil", tc.opt) + } + continue + } if err != nil { t.Fatalf("could not convert %+v (readOnly: %v) to string: %v", tc.opt, tc.readOnly, err) diff --git a/volume/mounts/parser_test.go b/volume/mounts/parser_test.go index f356fe8e36..c4af79055c 100644 --- a/volume/mounts/parser_test.go +++ b/volume/mounts/parser_test.go @@ -2,7 +2,6 @@ package mounts // import "github.com/docker/docker/volume/mounts" import ( "os" - "strings" "testing" "github.com/docker/docker/api/types/mount" @@ -10,70 +9,6 @@ import ( is "gotest.tools/v3/assert/cmp" ) -type parseMountRawTestSet struct { - valid []string - invalid map[string]string -} - -func TestConvertTmpfsOptions(t *testing.T) { - type testCase struct { - opt mount.TmpfsOptions - readOnly bool - expectedSubstrings []string - unexpectedSubstrings []string - err bool - } - cases := []testCase{ - { - opt: mount.TmpfsOptions{SizeBytes: 1024 * 1024, Mode: 0700}, - readOnly: false, - expectedSubstrings: []string{"size=1m", "mode=700"}, - unexpectedSubstrings: []string{"ro"}, - }, - { - opt: mount.TmpfsOptions{}, - readOnly: true, - expectedSubstrings: []string{"ro"}, - unexpectedSubstrings: []string{}, - }, - { - opt: mount.TmpfsOptions{Options: "exec"}, - readOnly: true, - expectedSubstrings: []string{"ro", "exec"}, - unexpectedSubstrings: []string{"noexec"}, - }, - { - opt: mount.TmpfsOptions{Options: "INVALID"}, - err: true, - }, - } - p := &linuxParser{} - for _, c := range cases { - data, err := p.ConvertTmpfsOptions(&c.opt, c.readOnly) - if c.err { - if err == nil { - t.Fatalf("expected error for %+v, got nil", c.opt) - } - continue - } - if err != nil { - t.Fatalf("could not convert %+v (readOnly: %v) to string: %v", - c.opt, c.readOnly, err) - } - t.Logf("data=%q", data) - for _, s := range c.expectedSubstrings { - if !strings.Contains(data, s) { - t.Fatalf("expected substring: %s, got %v (case=%+v)", s, data, c) - } - } - for _, s := range c.unexpectedSubstrings { - if strings.Contains(data, s) { - t.Fatalf("unexpected substring: %s, got %v (case=%+v)", s, data, c) - } - } - } -} - type mockFiProvider struct{} func (mockFiProvider) fileInfo(path string) (exists, isDir bool, err error) {