9 mounttypes "github.com/docker/docker/api/types/mount"
12 func TestConvertTmpfsOptions(t *testing.T) {
13 type testCase struct {
14 opt mounttypes.TmpfsOptions
16 expectedSubstrings []string
17 unexpectedSubstrings []string
21 opt: mounttypes.TmpfsOptions{SizeBytes: 1024 * 1024, Mode: 0700},
23 expectedSubstrings: []string{"size=1m", "mode=700"},
24 unexpectedSubstrings: []string{"ro"},
27 opt: mounttypes.TmpfsOptions{},
29 expectedSubstrings: []string{"ro"},
30 unexpectedSubstrings: []string{},
33 for _, c := range cases {
34 data, err := ConvertTmpfsOptions(&c.opt, c.readOnly)
36 t.Fatalf("could not convert %+v (readOnly: %v) to string: %v",
37 c.opt, c.readOnly, err)
39 t.Logf("data=%q", data)
40 for _, s := range c.expectedSubstrings {
41 if !strings.Contains(data, s) {
42 t.Fatalf("expected substring: %s, got %v (case=%+v)", s, data, c)
45 for _, s := range c.unexpectedSubstrings {
46 if strings.Contains(data, s) {
47 t.Fatalf("unexpected substring: %s, got %v (case=%+v)", s, data, c)