81fa9feb | package daemon |
a7e686a7 | import ( "testing" |
baba1a84 | "github.com/docker/docker/volume" |
a7e686a7 | ) |
81fa9feb | |
50be74ba | func TestParseVolumesFrom(t *testing.T) { |
81fa9feb | cases := []struct { spec string |
abd72d40 | expID string |
81fa9feb | expMode string fail bool }{ {"", "", "", true}, {"foobar", "foobar", "rw", false}, {"foobar:rw", "foobar", "rw", false}, {"foobar:ro", "foobar", "ro", false}, {"foobar:baz", "", "", true}, } for _, c := range cases { |
a7e686a7 | id, mode, err := volume.ParseVolumesFrom(c.spec) |
81fa9feb | if c.fail { if err == nil { t.Fatalf("Expected error, was nil, for spec %s\n", c.spec) } continue } |
abd72d40 | if id != c.expID { t.Fatalf("Expected id %s, was %s, for spec %s\n", c.expID, id, c.spec) |
81fa9feb | } if mode != c.expMode { t.Fatalf("Expected mode %s, was %s for spec %s\n", c.expMode, mode, c.spec) } } } |