github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/pkg/specgen/generate/kube/kube_test.go (about) 1 package kube 2 3 import ( 4 "testing" 5 6 v1 "github.com/hanks177/podman/v4/pkg/k8s.io/api/core/v1" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func testPropagation(t *testing.T, propagation v1.MountPropagationMode, expected string) { 11 dest, options, err := parseMountPath("/to", false, &propagation) 12 assert.NoError(t, err) 13 assert.Equal(t, dest, "/to") 14 assert.Contains(t, options, expected) 15 } 16 17 func TestParseMountPathPropagation(t *testing.T) { 18 testPropagation(t, v1.MountPropagationNone, "private") 19 testPropagation(t, v1.MountPropagationHostToContainer, "rslave") 20 testPropagation(t, v1.MountPropagationBidirectional, "rshared") 21 22 prop := v1.MountPropagationMode("SpaceWave") 23 _, _, err := parseMountPath("/to", false, &prop) 24 assert.Error(t, err) 25 26 _, options, err := parseMountPath("/to", false, nil) 27 assert.NoError(t, err) 28 assert.NotContains(t, options, "private") 29 assert.NotContains(t, options, "rslave") 30 assert.NotContains(t, options, "rshared") 31 } 32 33 func TestParseMountPathRO(t *testing.T) { 34 _, options, err := parseMountPath("/to", true, nil) 35 assert.NoError(t, err) 36 assert.Contains(t, options, "ro") 37 38 _, options, err = parseMountPath("/to", false, nil) 39 assert.NoError(t, err) 40 assert.NotContains(t, options, "ro") 41 }