mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
300c11c7c9
This changes mounts.NewParser() to create a parser for the current operatingsystem, instead of one specific to a (possibly non-matching, in case of LCOW) OS. With the OS-specific handling being removed, the "OS" parameter is also removed from `daemon.verifyContainerSettings()`, and various other container-related functions. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
41 lines
892 B
Go
41 lines
892 B
Go
package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
volumemounts "github.com/docker/docker/volume/mounts"
|
|
)
|
|
|
|
func TestParseVolumesFrom(t *testing.T) {
|
|
cases := []struct {
|
|
spec string
|
|
expID string
|
|
expMode string
|
|
fail bool
|
|
}{
|
|
{"", "", "", true},
|
|
{"foobar", "foobar", "rw", false},
|
|
{"foobar:rw", "foobar", "rw", false},
|
|
{"foobar:ro", "foobar", "ro", false},
|
|
{"foobar:baz", "", "", true},
|
|
}
|
|
|
|
parser := volumemounts.NewParser()
|
|
|
|
for _, c := range cases {
|
|
id, mode, err := parser.ParseVolumesFrom(c.spec)
|
|
if c.fail {
|
|
if err == nil {
|
|
t.Fatalf("Expected error, was nil, for spec %s\n", c.spec)
|
|
}
|
|
continue
|
|
}
|
|
|
|
if id != c.expID {
|
|
t.Fatalf("Expected id %s, was %s, for spec %s\n", c.expID, id, c.spec)
|
|
}
|
|
if mode != c.expMode {
|
|
t.Fatalf("Expected mode %s, was %s for spec %s\n", c.expMode, mode, c.spec)
|
|
}
|
|
}
|
|
}
|