mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-04 15:58:39 +00:00
dockerCmd when possible
Addresses: #14603 integration-cli/docker_cli_daemon_experimental_test.go (hqhq) integration-cli/docker_cli_daemon_test.go (hqhq) integration-cli/docker_cli_diff_test.go (hqhq) integration-cli/docker_cli_events_test.go (hqhq) integration-cli/docker_cli_events_unix_test.go (hqhq) integration-cli/docker_cli_exec_test.go (hqhq) integration-cli/docker_cli_exec_unix_test.go (hqhq) integration-cli/docker_cli_experimental_test.go (hqhq) integration-cli/docker_cli_export_import_test.go (hqhq) integration-cli/docker_cli_help_test.go (hqhq) integration-cli/docker_cli_history_test.go (hqhq) integration-cli/docker_cli_images_test.go (hqhq) integration-cli/docker_cli_import_test.go (hqhq) integration-cli/docker_cli_info_test.go (hqhq) integration-cli/docker_cli_inspect_test.go (hqhq) integration-cli/docker_cli_kill_test.go (hqhq) Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
@@ -11,14 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestImportDisplay(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to create a container", out, err)
|
||||
}
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
out, _, err = runCommandPipelineWithOutput(
|
||||
out, _, err := runCommandPipelineWithOutput(
|
||||
exec.Command(dockerBinary, "export", cleanedContainerID),
|
||||
exec.Command(dockerBinary, "import", "-"),
|
||||
)
|
||||
@@ -31,21 +27,14 @@ func (s *DockerSuite) TestImportDisplay(c *check.C) {
|
||||
}
|
||||
image := strings.TrimSpace(out)
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "run", "--rm", image, "true")
|
||||
out, _, err = runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to create a container", out, err)
|
||||
}
|
||||
|
||||
out, _ = dockerCmd(c, "run", "--rm", image, "true")
|
||||
if out != "" {
|
||||
c.Fatalf("command output should've been nothing, was %q", out)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImportBadURL(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "import", "http://nourl/bad")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
out, _, err := dockerCmdWithError(c, "import", "http://nourl/bad")
|
||||
if err == nil {
|
||||
c.Fatal("import was supposed to fail but didn't")
|
||||
}
|
||||
@@ -55,11 +44,7 @@ func (s *DockerSuite) TestImportBadURL(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImportFile(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "--name", "test-import", "busybox", "true")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to create a container", out, err)
|
||||
}
|
||||
dockerCmd(c, "run", "--name", "test-import", "busybox", "true")
|
||||
|
||||
temporaryFile, err := ioutil.TempFile("", "exportImportTest")
|
||||
if err != nil {
|
||||
@@ -67,42 +52,29 @@ func (s *DockerSuite) TestImportFile(c *check.C) {
|
||||
}
|
||||
defer os.Remove(temporaryFile.Name())
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "export", "test-import")
|
||||
runCmd := exec.Command(dockerBinary, "export", "test-import")
|
||||
runCmd.Stdout = bufio.NewWriter(temporaryFile)
|
||||
|
||||
_, err = runCommand(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to export a container", out, err)
|
||||
}
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "import", temporaryFile.Name())
|
||||
out, _, err = runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to import a container", out, err)
|
||||
c.Fatal("failed to export a container", err)
|
||||
}
|
||||
|
||||
out, _ := dockerCmd(c, "import", temporaryFile.Name())
|
||||
if n := strings.Count(out, "\n"); n != 1 {
|
||||
c.Fatalf("display is messed up: %d '\\n' instead of 1:\n%s", n, out)
|
||||
}
|
||||
image := strings.TrimSpace(out)
|
||||
|
||||
runCmd = exec.Command(dockerBinary, "run", "--rm", image, "true")
|
||||
out, _, err = runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal("failed to create a container", out, err)
|
||||
}
|
||||
|
||||
out, _ = dockerCmd(c, "run", "--rm", image, "true")
|
||||
if out != "" {
|
||||
c.Fatalf("command output should've been nothing, was %q", out)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestImportFileNonExistentFile(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "import", "example.com/myImage.tar")
|
||||
_, exitCode, err := runCommandWithOutput(runCmd)
|
||||
_, exitCode, err := dockerCmdWithError(c, "import", "example.com/myImage.tar")
|
||||
if exitCode == 0 || err == nil {
|
||||
c.Fatalf("import non-existing file must failed")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user