From 07fd173225408342de76f749c2a5bccadec32d3a Mon Sep 17 00:00:00 2001 From: John Howard Date: Tue, 2 Feb 2016 18:39:24 -0800 Subject: [PATCH] Windows CI: Port docker_cli_rm_test.go Signed-off-by: John Howard --- integration-cli/docker_cli_rm_test.go | 42 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/integration-cli/docker_cli_rm_test.go b/integration-cli/docker_cli_rm_test.go index ea2ca64035..088909ed4d 100644 --- a/integration-cli/docker_cli_rm_test.go +++ b/integration-cli/docker_cli_rm_test.go @@ -1,6 +1,7 @@ package main import ( + "io/ioutil" "os" "strings" @@ -9,34 +10,50 @@ import ( ) func (s *DockerSuite) TestRmContainerWithRemovedVolume(c *check.C) { - testRequires(c, DaemonIsLinux) testRequires(c, SameHostDaemon) - dockerCmd(c, "run", "--name", "losemyvolumes", "-v", "/tmp/testing:/test", "busybox", "true") + prefix := "" + slash := "/" + if daemonPlatform == "windows" { + prefix = "c:" + slash = `\` + } - err := os.Remove("/tmp/testing") + tempDir, err := ioutil.TempDir("", "test-rm-container-with-removed-volume-") + if err != nil { + c.Fatalf("failed to create temporary directory: %s", tempDir) + } + defer os.RemoveAll(tempDir) + + dockerCmd(c, "run", "--name", "losemyvolumes", "-v", tempDir+":"+prefix+slash+"test", "busybox", "true") + + err = os.RemoveAll(tempDir) c.Assert(err, check.IsNil) dockerCmd(c, "rm", "-v", "losemyvolumes") } func (s *DockerSuite) TestRmContainerWithVolume(c *check.C) { - testRequires(c, DaemonIsLinux) - dockerCmd(c, "run", "--name", "foo", "-v", "/srv", "busybox", "true") + prefix := "" + slash := "/" + if daemonPlatform == "windows" { + prefix = "c:" + slash = `\` + } + + dockerCmd(c, "run", "--name", "foo", "-v", prefix+slash+"srv", "busybox", "true") dockerCmd(c, "rm", "-v", "foo") } -func (s *DockerSuite) TestRmRunningContainer(c *check.C) { - testRequires(c, DaemonIsLinux) +func (s *DockerSuite) TestRmContainerRunning(c *check.C) { createRunningContainer(c, "foo") _, _, err := dockerCmdWithError("rm", "foo") c.Assert(err, checker.NotNil, check.Commentf("Expected error, can't rm a running container")) } -func (s *DockerSuite) TestRmForceRemoveRunningContainer(c *check.C) { - testRequires(c, DaemonIsLinux) +func (s *DockerSuite) TestRmContainerForceRemoveRunning(c *check.C) { createRunningContainer(c, "foo") // Stop then remove with -s @@ -44,12 +61,11 @@ func (s *DockerSuite) TestRmForceRemoveRunningContainer(c *check.C) { } func (s *DockerSuite) TestRmContainerOrphaning(c *check.C) { - testRequires(c, DaemonIsLinux) dockerfile1 := `FROM busybox:latest - ENTRYPOINT ["/bin/true"]` + ENTRYPOINT ["true"]` img := "test-container-orphaning" dockerfile2 := `FROM busybox:latest - ENTRYPOINT ["/bin/true"] + ENTRYPOINT ["true"] MAINTAINER Integration Tests` // build first dockerfile @@ -79,5 +95,5 @@ func (s *DockerSuite) TestRmInvalidContainer(c *check.C) { } func createRunningContainer(c *check.C, name string) { - dockerCmd(c, "run", "-dt", "--name", name, "busybox", "top") + runSleepingContainer(c, "-dt", "--name", name) }