Browse code

Cleanup errorOut resp in commit test

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)

Cleanup errorOut resp in commit test

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2014/10/15 03:26:53
Showing 1 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"fmt"
5 4
 	"os/exec"
6 5
 	"strings"
7 6
 	"testing"
... ...
@@ -10,23 +9,29 @@ import (
10 10
 func TestCommitAfterContainerIsDone(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
12 12
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
13
+	if err != nil {
14
+		t.Fatalf("failed to run container: %s, %v", out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
17 19
 	waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
18
-	_, _, err = runCommandWithOutput(waitCmd)
19
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
20
+	if _, _, err = runCommandWithOutput(waitCmd); err != nil {
21
+		t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
22
+	}
20 23
 
21 24
 	commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID)
22 25
 	out, _, err = runCommandWithOutput(commitCmd)
23
-	errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
26
+	if err != nil {
27
+		t.Fatalf("failed to commit container to image: %s, %v", out, err)
28
+	}
24 29
 
25 30
 	cleanedImageID := stripTrailingCharacters(out)
26 31
 
27 32
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
28
-	out, _, err = runCommandWithOutput(inspectCmd)
29
-	errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
33
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
34
+		t.Fatalf("failed to inspect image: %s, %v", out, err)
35
+	}
30 36
 
31 37
 	deleteContainer(cleanedContainerID)
32 38
 	deleteImages(cleanedImageID)
... ...
@@ -37,23 +42,29 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
37 37
 func TestCommitWithoutPause(t *testing.T) {
38 38
 	runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
39 39
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
40
-	errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
40
+	if err != nil {
41
+		t.Fatalf("failed to run container: %s, %v", out, err)
42
+	}
41 43
 
42 44
 	cleanedContainerID := stripTrailingCharacters(out)
43 45
 
44 46
 	waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
45
-	_, _, err = runCommandWithOutput(waitCmd)
46
-	errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
47
+	if _, _, err = runCommandWithOutput(waitCmd); err != nil {
48
+		t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
49
+	}
47 50
 
48 51
 	commitCmd := exec.Command(dockerBinary, "commit", "-p=false", cleanedContainerID)
49 52
 	out, _, err = runCommandWithOutput(commitCmd)
50
-	errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
53
+	if err != nil {
54
+		t.Fatalf("failed to commit container to image: %s, %v", out, err)
55
+	}
51 56
 
52 57
 	cleanedImageID := stripTrailingCharacters(out)
53 58
 
54 59
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
55
-	out, _, err = runCommandWithOutput(inspectCmd)
56
-	errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
60
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
61
+		t.Fatalf("failed to inspect image: %s, %v", out, err)
62
+	}
57 63
 
58 64
 	deleteContainer(cleanedContainerID)
59 65
 	deleteImages(cleanedImageID)
... ...
@@ -81,7 +92,7 @@ func TestCommitNewFile(t *testing.T) {
81 81
 		t.Fatal(err, out)
82 82
 	}
83 83
 	if actual := strings.Trim(out, "\r\n"); actual != "koye" {
84
-		t.Fatalf("expected output koye received %s", actual)
84
+		t.Fatalf("expected output koye received %q", actual)
85 85
 	}
86 86
 
87 87
 	deleteAllContainers()
... ...
@@ -92,7 +103,6 @@ func TestCommitNewFile(t *testing.T) {
92 92
 
93 93
 func TestCommitTTY(t *testing.T) {
94 94
 	cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
95
-
96 95
 	if _, err := runCommand(cmd); err != nil {
97 96
 		t.Fatal(err)
98 97
 	}
... ...
@@ -105,7 +115,6 @@ func TestCommitTTY(t *testing.T) {
105 105
 	imageID = strings.Trim(imageID, "\r\n")
106 106
 
107 107
 	cmd = exec.Command(dockerBinary, "run", "ttytest", "/bin/ls")
108
-
109 108
 	if _, err := runCommand(cmd); err != nil {
110 109
 		t.Fatal(err)
111 110
 	}
... ...
@@ -124,6 +133,7 @@ func TestCommitWithHostBindMount(t *testing.T) {
124 124
 	if err != nil {
125 125
 		t.Fatal(imageID, err)
126 126
 	}
127
+
127 128
 	imageID = strings.Trim(imageID, "\r\n")
128 129
 
129 130
 	cmd = exec.Command(dockerBinary, "run", "bindtest", "true")