2015-05-19 23:05:25 +03:00
|
|
|
package daemon
|
|
|
|
|
2015-09-10 05:23:06 +03:00
|
|
|
import (
|
|
|
|
"testing"
|
2015-12-16 18:35:35 +03:00
|
|
|
|
|
|
|
"github.com/docker/docker/volume"
|
2015-09-10 05:23:06 +03:00
|
|
|
)
|
2015-05-19 23:05:25 +03:00
|
|
|
|
2015-08-31 05:48:34 +03:00
|
|
|
func TestParseVolumesFrom(t *testing.T) {
|
2015-05-19 23:05:25 +03:00
|
|
|
cases := []struct {
|
|
|
|
spec string
|
2015-07-31 00:01:53 +03:00
|
|
|
expID string
|
2015-05-19 23:05:25 +03:00
|
|
|
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 {
|
2015-09-10 05:23:06 +03:00
|
|
|
id, mode, err := volume.ParseVolumesFrom(c.spec)
|
2015-05-19 23:05:25 +03:00
|
|
|
if c.fail {
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("Expected error, was nil, for spec %s\n", c.spec)
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2015-07-31 00:01:53 +03:00
|
|
|
if id != c.expID {
|
|
|
|
t.Fatalf("Expected id %s, was %s, for spec %s\n", c.expID, id, c.spec)
|
2015-05-19 23:05:25 +03:00
|
|
|
}
|
|
|
|
if mode != c.expMode {
|
|
|
|
t.Fatalf("Expected mode %s, was %s for spec %s\n", c.expMode, mode, c.spec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|