github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/spec/storage_test.go (about) 1 package createconfig 2 3 import ( 4 "testing" 5 6 spec "github.com/opencontainers/runtime-spec/specs-go" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestGetVolumeMountsOneVolume(t *testing.T) { 11 data := spec.Mount{ 12 Destination: "/foobar", 13 Type: "bind", 14 Source: "/tmp", 15 Options: []string{"ro"}, 16 } 17 config := CreateConfig{ 18 Volumes: []string{"/tmp:/foobar:ro"}, 19 } 20 specMount, _, err := config.getVolumeMounts() 21 assert.NoError(t, err) 22 assert.EqualValues(t, data, specMount[data.Destination]) 23 } 24 25 func TestGetTmpfsMounts(t *testing.T) { 26 data := spec.Mount{ 27 Destination: "/homer", 28 Type: "tmpfs", 29 Source: "tmpfs", 30 Options: []string{"rw", "size=787448k", "mode=1777"}, 31 } 32 config := CreateConfig{ 33 Tmpfs: []string{"/homer:rw,size=787448k,mode=1777"}, 34 } 35 tmpfsMount, err := config.getTmpfsMounts() 36 assert.NoError(t, err) 37 assert.EqualValues(t, data, tmpfsMount[data.Destination]) 38 }