summaryrefslogtreecommitdiff
path: root/volume/mounts
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2021-07-02 13:27:57 +0200
committerSebastiaan van Stijn <github@gone.nl>2021-07-02 14:05:04 +0200
commit536818508d12e44d2598ebd69a4baf8ed602f20e (patch)
tree5d1ed09dca21ba80fca18aa204d7e389428c0538 /volume/mounts
parent300c11c7c9143ca077890050deb83917e67fe250 (diff)
downloaddocker-536818508d12e44d2598ebd69a4baf8ed602f20e.tar.gz
volume/mounts: move TestConvertTmpfsOptions
It's only testing the LinuxParser, so moving it to a file specific to that code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'volume/mounts')
-rw-r--r--volume/mounts/linux_parser_test.go50
-rw-r--r--volume/mounts/parser_test.go42
2 files changed, 50 insertions, 42 deletions
diff --git a/volume/mounts/linux_parser_test.go b/volume/mounts/linux_parser_test.go
new file mode 100644
index 0000000000..ad56a502f6
--- /dev/null
+++ b/volume/mounts/linux_parser_test.go
@@ -0,0 +1,50 @@
+package mounts // import "github.com/docker/docker/volume/mounts"
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/docker/docker/api/types/mount"
+)
+
+func TestConvertTmpfsOptions(t *testing.T) {
+ type testCase struct {
+ opt mount.TmpfsOptions
+ readOnly bool
+ expectedSubstrings []string
+ unexpectedSubstrings []string
+ }
+ 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{},
+ },
+ }
+ p := &linuxParser{}
+ for _, c := range cases {
+ data, err := p.ConvertTmpfsOptions(&c.opt, c.readOnly)
+ 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)
+ }
+ }
+ }
+}
diff --git a/volume/mounts/parser_test.go b/volume/mounts/parser_test.go
index 9aadcc02dc..029da80857 100644
--- a/volume/mounts/parser_test.go
+++ b/volume/mounts/parser_test.go
@@ -17,48 +17,6 @@ type parseMountRawTestSet struct {
invalid map[string]string
}
-func TestConvertTmpfsOptions(t *testing.T) {
- type testCase struct {
- opt mount.TmpfsOptions
- readOnly bool
- expectedSubstrings []string
- unexpectedSubstrings []string
- }
- 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{},
- },
- }
- p := &linuxParser{}
- for _, c := range cases {
- data, err := p.ConvertTmpfsOptions(&c.opt, c.readOnly)
- 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) {