github.com/containers/podman/v4@v4.9.4/pkg/specgen/generate/config_common_test.go (about) 1 //go:build !remote 2 // +build !remote 3 4 package generate 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestParseDevice(t *testing.T) { 13 tests := []struct { 14 device string 15 src string 16 dst string 17 perm string 18 }{ 19 {"/dev/foo", "/dev/foo", "/dev/foo", "rwm"}, 20 {"/dev/foo:/dev/bar", "/dev/foo", "/dev/bar", "rwm"}, 21 {"/dev/foo:/dev/bar:rw", "/dev/foo", "/dev/bar", "rw"}, 22 {"/dev/foo:rw", "/dev/foo", "/dev/foo", "rw"}, 23 {"/dev/foo::rw", "/dev/foo", "/dev/foo", "rw"}, 24 } 25 for _, test := range tests { 26 src, dst, perm, err := ParseDevice(test.device) 27 assert.NoError(t, err) 28 assert.Equal(t, src, test.src) 29 assert.Equal(t, dst, test.dst) 30 assert.Equal(t, perm, test.perm) 31 } 32 }