mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-03 04:01:31 +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:
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/go-check/check"
|
||||
@@ -10,19 +9,10 @@ import (
|
||||
// ensure that an added file shows up in docker diff
|
||||
func (s *DockerSuite) TestDiffFilenameShownInOutput(c *check.C) {
|
||||
containerCmd := `echo foo > /root/bar`
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to start the container: %s, %v", out, err)
|
||||
}
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", containerCmd)
|
||||
|
||||
cleanCID := strings.TrimSpace(out)
|
||||
|
||||
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
|
||||
out, _, err = runCommandWithOutput(diffCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to run diff: %s %v", out, err)
|
||||
}
|
||||
out, _ = dockerCmd(c, "diff", cleanCID)
|
||||
|
||||
found := false
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
@@ -45,20 +35,10 @@ func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
|
||||
// we might not run into this problem from the first run, so start a few containers
|
||||
for i := 0; i < containerCount; i++ {
|
||||
containerCmd := `echo foo > /root/bar`
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd)
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", containerCmd)
|
||||
|
||||
cleanCID := strings.TrimSpace(out)
|
||||
|
||||
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
|
||||
out, _, err = runCommandWithOutput(diffCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to run diff: %s, %v", out, err)
|
||||
}
|
||||
out, _ = dockerCmd(c, "diff", cleanCID)
|
||||
|
||||
for _, filename := range dockerinitFiles {
|
||||
if strings.Contains(out, filename) {
|
||||
@@ -69,19 +49,10 @@ func (s *DockerSuite) TestDiffEnsureDockerinitFilesAreIgnored(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestDiffEnsureOnlyKmsgAndPtmx(c *check.C) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep", "0")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
if err != nil {
|
||||
c.Fatal(out, err)
|
||||
}
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sleep", "0")
|
||||
|
||||
cleanCID := strings.TrimSpace(out)
|
||||
|
||||
diffCmd := exec.Command(dockerBinary, "diff", cleanCID)
|
||||
out, _, err = runCommandWithOutput(diffCmd)
|
||||
if err != nil {
|
||||
c.Fatalf("failed to run diff: %s, %v", out, err)
|
||||
}
|
||||
out, _ = dockerCmd(c, "diff", cleanCID)
|
||||
|
||||
expected := map[string]bool{
|
||||
"C /dev": true,
|
||||
@@ -111,7 +82,7 @@ func (s *DockerSuite) TestDiffEnsureOnlyKmsgAndPtmx(c *check.C) {
|
||||
|
||||
// https://github.com/docker/docker/pull/14381#discussion_r33859347
|
||||
func (s *DockerSuite) TestDiffEmptyArgClientError(c *check.C) {
|
||||
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "diff", ""))
|
||||
out, _, err := dockerCmdWithError(c, "diff", "")
|
||||
c.Assert(err, check.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), check.Equals, "Container name cannot be empty")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user