diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index c6a0048c5bf65518c08bd1d488a304279dc3350d..c3839aad66551eed0adced78e10c33bb59e62664 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -1971,22 +1971,22 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) { assert.NilError(c, err) defer os.RemoveAll(tmpDir3) - assert.Assert(c, mountWrapper(tmpDir3, tmpDir3, "none", "bind,shared") == nil) - - cases = append(cases, []testCase{ - { - spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath}, - expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3}, - }, - { - spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true}, - expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3}, - }, - { - spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mount.BindOptions{Propagation: "shared"}}, - expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"}, - }, - }...) + if assert.Check(c, mountWrapper(c, tmpDir3, tmpDir3, "none", "bind,shared")) { + cases = append(cases, []testCase{ + { + spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath}, + expected: types.MountPoint{Type: "bind", RW: true, Destination: destPath, Source: tmpDir3}, + }, + { + spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true}, + expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3}, + }, + { + spec: mount.Mount{Type: "bind", Source: tmpDir3, Target: destPath, ReadOnly: true, BindOptions: &mount.BindOptions{Propagation: "shared"}}, + expected: types.MountPoint{Type: "bind", RW: false, Destination: destPath, Source: tmpDir3, Propagation: "shared"}, + }, + }...) + } } } diff --git a/integration-cli/docker_api_containers_unix_test.go b/integration-cli/docker_api_containers_unix_test.go index 1477550bda57338b873e7d4a2108e9b0aa9cd789..135de95d029e850be6f5a657afcbdad7bb8c209d 100644 --- a/integration-cli/docker_api_containers_unix_test.go +++ b/integration-cli/docker_api_containers_unix_test.go @@ -2,8 +2,18 @@ package main -import "github.com/moby/sys/mount" +import ( + "testing" -func mountWrapper(device, target, mType, options string) error { - return mount.Mount(device, target, mType, options) + "github.com/moby/sys/mount" +) + +func mountWrapper(t *testing.T, device, target, mType, options string) error { + t.Helper() + err := mount.Mount(device, target, mType, options) + if err != nil { + return err + } + t.Cleanup(func() { _ = mount.Unmount(target) }) + return nil } diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go index 4c0be31e4f22ee189da66fb6fb96e9abf98802e7..e87ccfe17f4a32bbd133fca4a598ad063ed05e05 100644 --- a/integration-cli/docker_api_containers_windows_test.go +++ b/integration-cli/docker_api_containers_windows_test.go @@ -73,7 +73,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T assert.Check(c, is.Equal(text, strings.TrimSpace(string(b)))) } -func mountWrapper(device, target, mType, options string) error { +func mountWrapper(t *testing.T, device, target, mType, options string) error { // This should never be called. return errors.Errorf("there is no implementation of Mount on this platform") } diff --git a/integration-cli/docker_cli_run_unix_test.go b/integration-cli/docker_cli_run_unix_test.go index 75dca04debf9cd3a53fd5a49581e8d043124313e..28ce7153284981a567df8c05392f8319bd6a0760 100644 --- a/integration-cli/docker_cli_run_unix_test.go +++ b/integration-cli/docker_cli_run_unix_test.go @@ -70,6 +70,7 @@ func (s *DockerCLIRunSuite) TestRunWithVolumesIsRecursive(c *testing.T) { tmpfsDir := filepath.Join(tmpDir, "tmpfs") assert.Assert(c, os.MkdirAll(tmpfsDir, 0o777) == nil, "failed to mkdir at %s", tmpfsDir) assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir) + defer mount.Unmount(tmpfsDir) f, err := os.CreateTemp(tmpfsDir, "touch-me") assert.NilError(c, err)