|
@@ -76,7 +76,7 @@ func TestMountOptString(t *testing.T) {
|
|
|
assert.Equal(t, mount.String(), expected)
|
|
|
}
|
|
|
|
|
|
-func TestMountOptSetNoError(t *testing.T) {
|
|
|
+func TestMountOptSetBindNoErrorBind(t *testing.T) {
|
|
|
for _, testcase := range []string{
|
|
|
// tests several aliases that should have same result.
|
|
|
"type=bind,target=/target,source=/source",
|
|
@@ -98,6 +98,28 @@ func TestMountOptSetNoError(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestMountOptSetVolumeNoError(t *testing.T) {
|
|
|
+ for _, testcase := range []string{
|
|
|
+ // tests several aliases that should have same result.
|
|
|
+ "type=volume,target=/target,source=/source",
|
|
|
+ "type=volume,src=/source,dst=/target",
|
|
|
+ "type=volume,source=/source,dst=/target",
|
|
|
+ "type=volume,src=/source,target=/target",
|
|
|
+ } {
|
|
|
+ var mount MountOpt
|
|
|
+
|
|
|
+ assert.NilError(t, mount.Set(testcase))
|
|
|
+
|
|
|
+ mounts := mount.Value()
|
|
|
+ assert.Equal(t, len(mounts), 1)
|
|
|
+ assert.Equal(t, mounts[0], mounttypes.Mount{
|
|
|
+ Type: mounttypes.TypeVolume,
|
|
|
+ Source: "/source",
|
|
|
+ Target: "/target",
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// TestMountOptDefaultType ensures that a mount without the type defaults to a
|
|
|
// volume mount.
|
|
|
func TestMountOptDefaultType(t *testing.T) {
|
|
@@ -140,6 +162,10 @@ func TestMountOptDefaultEnableReadOnly(t *testing.T) {
|
|
|
assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=1"))
|
|
|
assert.Equal(t, m.values[0].ReadOnly, true)
|
|
|
|
|
|
+ m = MountOpt{}
|
|
|
+ assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=true"))
|
|
|
+ assert.Equal(t, m.values[0].ReadOnly, true)
|
|
|
+
|
|
|
m = MountOpt{}
|
|
|
assert.NilError(t, m.Set("type=bind,target=/foo,source=/foo,readonly=0"))
|
|
|
assert.Equal(t, m.values[0].ReadOnly, false)
|
|
@@ -147,7 +173,8 @@ func TestMountOptDefaultEnableReadOnly(t *testing.T) {
|
|
|
|
|
|
func TestMountOptVolumeNoCopy(t *testing.T) {
|
|
|
var m MountOpt
|
|
|
- assert.Error(t, m.Set("type=volume,target=/foo,volume-nocopy"), "source is required")
|
|
|
+ assert.NilError(t, m.Set("type=volume,target=/foo,volume-nocopy"))
|
|
|
+ assert.Equal(t, m.values[0].Source, "")
|
|
|
|
|
|
m = MountOpt{}
|
|
|
assert.NilError(t, m.Set("type=volume,target=/foo,source=foo"))
|