зеркало из https://github.com/microsoft/docker.git
Windows CI: Port docker_cli_rm_test.go
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
Родитель
c2bf90eb59
Коммит
07fd173225
|
@ -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)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче