package docker //nolint:testpackage // tests unexported buildMounts import ( "testing" "github.com/docker/docker/api/types/mount" "github.com/stretchr/testify/assert" ) // TestBuildMountsCreatesMissingHostPath checks that every mount asks Docker // to create its host path if it is missing, and keeps the rest of the volume // as configured. func TestBuildMountsCreatesMissingHostPath(t *testing.T) { t.Parallel() volumes := []VolumeMount{ {HostPath: "/srv/app/data", ContainerPath: "/data", ReadOnly: false}, {HostPath: "/srv/app/config", ContainerPath: "/etc/app", ReadOnly: true}, } want := []mount.Mount{ { Type: mount.TypeBind, Source: "/srv/app/data", Target: "/data", ReadOnly: false, BindOptions: &mount.BindOptions{CreateMountpoint: true}, }, { Type: mount.TypeBind, Source: "/srv/app/config", Target: "/etc/app", ReadOnly: true, BindOptions: &mount.BindOptions{CreateMountpoint: true}, }, } assert.Equal(t, want, buildMounts(volumes)) }