From 7bb729e928d995bf6f358d38cf1251611dab8106 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Fri, 6 Nov 2020 01:23:49 +1100 Subject: [PATCH] Break out non-Windows sys/mount usage into helper Rather than bifurcate the test completely, this lets us keep the test intact with a small function wrapper to allow the compiler to build the code that'll never be called on Windows, on Windows. Signed-off-by: Paul "TBBle" Hampson --- integration-cli/docker_api_containers_test.go | 3 +-- integration-cli/docker_api_containers_unix_test.go | 9 +++++++++ integration-cli/docker_api_containers_windows_test.go | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 integration-cli/docker_api_containers_unix_test.go diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 720a909bd0..76ce061e7d 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -30,7 +30,6 @@ import ( "github.com/docker/docker/testutil/request" "github.com/docker/docker/volume" "github.com/docker/go-connections/nat" - "github.com/moby/sys/mount" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/poll" @@ -2056,7 +2055,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *testing.T) { assert.NilError(c, err) defer os.RemoveAll(tmpDir3) - assert.Assert(c, mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared") == nil) + assert.Assert(c, mountWrapper(tmpDir3, tmpDir3, "none", "bind,shared") == nil) cases = append(cases, []testCase{ { diff --git a/integration-cli/docker_api_containers_unix_test.go b/integration-cli/docker_api_containers_unix_test.go new file mode 100644 index 0000000000..05c667fa69 --- /dev/null +++ b/integration-cli/docker_api_containers_unix_test.go @@ -0,0 +1,9 @@ +// +build !windows + +package main + +import "github.com/moby/sys/mount" + +func mountWrapper(device, target, mType, options string) error { + return mount.Mount(device, target, mType, options) +} diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go index 0423d18426..1038506bee 100644 --- a/integration-cli/docker_api_containers_windows_test.go +++ b/integration-cli/docker_api_containers_windows_test.go @@ -15,6 +15,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" + "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -75,3 +76,8 @@ func (s *DockerSuite) TestContainersAPICreateMountsBindNamedPipe(c *testing.T) { assert.NilError(c, err) assert.Check(c, is.Equal(text, strings.TrimSpace(string(b)))) } + +func mountWrapper(device, target, mType, options string) error { + // This should never be called. + return errors.Errorf("there is no implementation of Mount on this platform") +}