From 198fd58622c55ca69e163da21c7a0bfdcf985cf1 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Tue, 14 Oct 2014 12:56:13 -0700 Subject: [PATCH] Cleanup errorOut resp in diff test Docker-DCO-1.1-Signed-off-by: Jessica Frazelle (github: jfrazelle) Upstream-commit: ac62c5439ac6197c3afca66db4489f96296097b6 Component: engine --- .../integration-cli/docker_cli_diff_test.go | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_diff_test.go b/components/engine/integration-cli/docker_cli_diff_test.go index c6bf2bbd18..4068140ce2 100644 --- a/components/engine/integration-cli/docker_cli_diff_test.go +++ b/components/engine/integration-cli/docker_cli_diff_test.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os/exec" "strings" "testing" @@ -11,14 +10,18 @@ import ( func TestDiffFilenameShownInOutput(t *testing.T) { containerCmd := `echo foo > /root/bar` runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd) - cid, _, err := runCommandWithOutput(runCmd) - errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err)) + out, _, err := runCommandWithOutput(runCmd) + if err != nil { + t.Fatalf("failed to start the container: %s, %v", out, err) + } - cleanCID := stripTrailingCharacters(cid) + cleanCID := stripTrailingCharacters(out) diffCmd := exec.Command(dockerBinary, "diff", cleanCID) - out, _, err := runCommandWithOutput(diffCmd) - errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err)) + out, _, err = runCommandWithOutput(diffCmd) + if err != nil { + t.Fatalf("failed to run diff: %s %v", out, err) + } found := false for _, line := range strings.Split(out, "\n") { @@ -44,14 +47,18 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) { for i := 0; i < 20; i++ { containerCmd := `echo foo > /root/bar` runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", containerCmd) - cid, _, err := runCommandWithOutput(runCmd) - errorOut(err, t, fmt.Sprintf("%s", err)) + out, _, err := runCommandWithOutput(runCmd) + if err != nil { + t.Fatal(out, err) + } - cleanCID := stripTrailingCharacters(cid) + cleanCID := stripTrailingCharacters(out) diffCmd := exec.Command(dockerBinary, "diff", cleanCID) - out, _, err := runCommandWithOutput(diffCmd) - errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err)) + out, _, err = runCommandWithOutput(diffCmd) + if err != nil { + t.Fatalf("failed to run diff: %s, %v", out, err) + } deleteContainer(cleanCID) @@ -67,13 +74,18 @@ func TestDiffEnsureDockerinitFilesAreIgnored(t *testing.T) { func TestDiffEnsureOnlyKmsgAndPtmx(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sleep", "0") - cid, _, err := runCommandWithOutput(runCmd) - errorOut(err, t, fmt.Sprintf("%s", err)) - cleanCID := stripTrailingCharacters(cid) + out, _, err := runCommandWithOutput(runCmd) + if err != nil { + t.Fatal(out, err) + } + + cleanCID := stripTrailingCharacters(out) diffCmd := exec.Command(dockerBinary, "diff", cleanCID) - out, _, err := runCommandWithOutput(diffCmd) - errorOut(err, t, fmt.Sprintf("failed to run diff: %v %v", out, err)) + out, _, err = runCommandWithOutput(diffCmd) + if err != nil { + t.Fatalf("failed to run diff: %s, %v", out, err) + } deleteContainer(cleanCID) expected := map[string]bool{