Initial commit
This commit is contained in:
39
vendor/github.com/hyperhq/hypercli/daemon/volumes_unit_test.go
generated
vendored
Normal file
39
vendor/github.com/hyperhq/hypercli/daemon/volumes_unit_test.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package daemon
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hyperhq/hypercli/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},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
id, mode, err := volume.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user