reg/vendor/github.com/docker/docker-ce/components/engine/daemon/volumes_unit_test.go
Jess Frazelle ab6c553e6b
update deps
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
2018-03-06 10:41:43 -05:00

43 lines
889 B
Go

package daemon // import "github.com/docker/docker/daemon"
import (
"runtime"
"testing"
"github.com/docker/docker/volume"
)
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 := volume.NewParser(runtime.GOOS)
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)
}
}
}