Browse code

Cleanup errorOut resp in ps tests

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

Jessica Frazelle authored on 2014/10/15 05:04:37
Showing 1 changed files
... ...
@@ -10,34 +10,45 @@ import (
10 10
 func TestPsListContainers(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "top")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, out)
13
+	if err != nil {
14
+		t.Fatal(out, err)
15
+	}
14 16
 	firstID := stripTrailingCharacters(out)
15 17
 
16 18
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
17 19
 	out, _, err = runCommandWithOutput(runCmd)
18
-	errorOut(err, t, out)
20
+	if err != nil {
21
+		t.Fatal(out, err)
22
+	}
19 23
 	secondID := stripTrailingCharacters(out)
20 24
 
21 25
 	// not long running
22 26
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "true")
23 27
 	out, _, err = runCommandWithOutput(runCmd)
24
-	errorOut(err, t, out)
28
+	if err != nil {
29
+		t.Fatal(out, err)
30
+	}
25 31
 	thirdID := stripTrailingCharacters(out)
26 32
 
27 33
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "top")
28 34
 	out, _, err = runCommandWithOutput(runCmd)
29
-	errorOut(err, t, out)
35
+	if err != nil {
36
+		t.Fatal(out, err)
37
+	}
30 38
 	fourthID := stripTrailingCharacters(out)
31 39
 
32 40
 	// make sure third one is not running
33 41
 	runCmd = exec.Command(dockerBinary, "wait", thirdID)
34
-	out, _, err = runCommandWithOutput(runCmd)
35
-	errorOut(err, t, out)
42
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
43
+		t.Fatal(out, err)
44
+	}
36 45
 
37 46
 	// all
38 47
 	runCmd = exec.Command(dockerBinary, "ps", "-a")
39 48
 	out, _, err = runCommandWithOutput(runCmd)
40
-	errorOut(err, t, out)
49
+	if err != nil {
50
+		t.Fatal(out, err)
51
+	}
41 52
 
42 53
 	if !assertContainerList(out, []string{fourthID, thirdID, secondID, firstID}) {
43 54
 		t.Error("Container list is not in the correct order")
... ...
@@ -46,7 +57,9 @@ func TestPsListContainers(t *testing.T) {
46 46
 	// running
47 47
 	runCmd = exec.Command(dockerBinary, "ps")
48 48
 	out, _, err = runCommandWithOutput(runCmd)
49
-	errorOut(err, t, out)
49
+	if err != nil {
50
+		t.Fatal(out, err)
51
+	}
50 52
 
51 53
 	if !assertContainerList(out, []string{fourthID, secondID, firstID}) {
52 54
 		t.Error("Container list is not in the correct order")
... ...
@@ -57,7 +70,9 @@ func TestPsListContainers(t *testing.T) {
57 57
 	// limit
58 58
 	runCmd = exec.Command(dockerBinary, "ps", "-n=2", "-a")
59 59
 	out, _, err = runCommandWithOutput(runCmd)
60
-	errorOut(err, t, out)
60
+	if err != nil {
61
+		t.Fatal(out, err)
62
+	}
61 63
 	expected := []string{fourthID, thirdID}
62 64
 
63 65
 	if !assertContainerList(out, expected) {
... ...
@@ -66,7 +81,9 @@ func TestPsListContainers(t *testing.T) {
66 66
 
67 67
 	runCmd = exec.Command(dockerBinary, "ps", "-n=2")
68 68
 	out, _, err = runCommandWithOutput(runCmd)
69
-	errorOut(err, t, out)
69
+	if err != nil {
70
+		t.Fatal(out, err)
71
+	}
70 72
 
71 73
 	if !assertContainerList(out, expected) {
72 74
 		t.Error("Container list is not in the correct order")
... ...
@@ -75,7 +92,9 @@ func TestPsListContainers(t *testing.T) {
75 75
 	// since
76 76
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-a")
77 77
 	out, _, err = runCommandWithOutput(runCmd)
78
-	errorOut(err, t, out)
78
+	if err != nil {
79
+		t.Fatal(out, err)
80
+	}
79 81
 	expected = []string{fourthID, thirdID, secondID}
80 82
 
81 83
 	if !assertContainerList(out, expected) {
... ...
@@ -84,7 +103,9 @@ func TestPsListContainers(t *testing.T) {
84 84
 
85 85
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID)
86 86
 	out, _, err = runCommandWithOutput(runCmd)
87
-	errorOut(err, t, out)
87
+	if err != nil {
88
+		t.Fatal(out, err)
89
+	}
88 90
 
89 91
 	if !assertContainerList(out, expected) {
90 92
 		t.Error("Container list is not in the correct order")
... ...
@@ -93,7 +114,9 @@ func TestPsListContainers(t *testing.T) {
93 93
 	// before
94 94
 	runCmd = exec.Command(dockerBinary, "ps", "--before", thirdID, "-a")
95 95
 	out, _, err = runCommandWithOutput(runCmd)
96
-	errorOut(err, t, out)
96
+	if err != nil {
97
+		t.Fatal(out, err)
98
+	}
97 99
 	expected = []string{secondID, firstID}
98 100
 
99 101
 	if !assertContainerList(out, expected) {
... ...
@@ -102,7 +125,9 @@ func TestPsListContainers(t *testing.T) {
102 102
 
103 103
 	runCmd = exec.Command(dockerBinary, "ps", "--before", thirdID)
104 104
 	out, _, err = runCommandWithOutput(runCmd)
105
-	errorOut(err, t, out)
105
+	if err != nil {
106
+		t.Fatal(out, err)
107
+	}
106 108
 
107 109
 	if !assertContainerList(out, expected) {
108 110
 		t.Error("Container list is not in the correct order")
... ...
@@ -111,7 +136,9 @@ func TestPsListContainers(t *testing.T) {
111 111
 	// since & before
112 112
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-a")
113 113
 	out, _, err = runCommandWithOutput(runCmd)
114
-	errorOut(err, t, out)
114
+	if err != nil {
115
+		t.Fatal(out, err)
116
+	}
115 117
 	expected = []string{thirdID, secondID}
116 118
 
117 119
 	if !assertContainerList(out, expected) {
... ...
@@ -120,7 +147,9 @@ func TestPsListContainers(t *testing.T) {
120 120
 
121 121
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID)
122 122
 	out, _, err = runCommandWithOutput(runCmd)
123
-	errorOut(err, t, out)
123
+	if err != nil {
124
+		t.Fatal(out, err)
125
+	}
124 126
 	if !assertContainerList(out, expected) {
125 127
 		t.Error("Container list is not in the correct order")
126 128
 	}
... ...
@@ -128,7 +157,9 @@ func TestPsListContainers(t *testing.T) {
128 128
 	// since & limit
129 129
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-n=2", "-a")
130 130
 	out, _, err = runCommandWithOutput(runCmd)
131
-	errorOut(err, t, out)
131
+	if err != nil {
132
+		t.Fatal(out, err)
133
+	}
132 134
 	expected = []string{fourthID, thirdID}
133 135
 
134 136
 	if !assertContainerList(out, expected) {
... ...
@@ -137,7 +168,9 @@ func TestPsListContainers(t *testing.T) {
137 137
 
138 138
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "-n=2")
139 139
 	out, _, err = runCommandWithOutput(runCmd)
140
-	errorOut(err, t, out)
140
+	if err != nil {
141
+		t.Fatal(out, err)
142
+	}
141 143
 
142 144
 	if !assertContainerList(out, expected) {
143 145
 		t.Error("Container list is not in the correct order")
... ...
@@ -146,7 +179,9 @@ func TestPsListContainers(t *testing.T) {
146 146
 	// before & limit
147 147
 	runCmd = exec.Command(dockerBinary, "ps", "--before", fourthID, "-n=1", "-a")
148 148
 	out, _, err = runCommandWithOutput(runCmd)
149
-	errorOut(err, t, out)
149
+	if err != nil {
150
+		t.Fatal(out, err)
151
+	}
150 152
 	expected = []string{thirdID}
151 153
 
152 154
 	if !assertContainerList(out, expected) {
... ...
@@ -155,7 +190,9 @@ func TestPsListContainers(t *testing.T) {
155 155
 
156 156
 	runCmd = exec.Command(dockerBinary, "ps", "--before", fourthID, "-n=1")
157 157
 	out, _, err = runCommandWithOutput(runCmd)
158
-	errorOut(err, t, out)
158
+	if err != nil {
159
+		t.Fatal(out, err)
160
+	}
159 161
 
160 162
 	if !assertContainerList(out, expected) {
161 163
 		t.Error("Container list is not in the correct order")
... ...
@@ -164,7 +201,9 @@ func TestPsListContainers(t *testing.T) {
164 164
 	// since & before & limit
165 165
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-n=1", "-a")
166 166
 	out, _, err = runCommandWithOutput(runCmd)
167
-	errorOut(err, t, out)
167
+	if err != nil {
168
+		t.Fatal(out, err)
169
+	}
168 170
 	expected = []string{thirdID}
169 171
 
170 172
 	if !assertContainerList(out, expected) {
... ...
@@ -173,7 +212,9 @@ func TestPsListContainers(t *testing.T) {
173 173
 
174 174
 	runCmd = exec.Command(dockerBinary, "ps", "--since", firstID, "--before", fourthID, "-n=1")
175 175
 	out, _, err = runCommandWithOutput(runCmd)
176
-	errorOut(err, t, out)
176
+	if err != nil {
177
+		t.Fatal(out, err)
178
+	}
177 179
 
178 180
 	if !assertContainerList(out, expected) {
179 181
 		t.Error("Container list is not in the correct order")
... ...
@@ -205,7 +246,9 @@ func TestPsListContainersSize(t *testing.T) {
205 205
 	name := "test_size"
206 206
 	runCmd := exec.Command(dockerBinary, "run", "--name", name, "busybox", "sh", "-c", "echo 1 > test")
207 207
 	out, _, err := runCommandWithOutput(runCmd)
208
-	errorOut(err, t, out)
208
+	if err != nil {
209
+		t.Fatal(out, err)
210
+	}
209 211
 	id, err := getIDByName(name)
210 212
 	if err != nil {
211 213
 		t.Fatal(err)
... ...
@@ -222,7 +265,9 @@ func TestPsListContainersSize(t *testing.T) {
222 222
 	case <-time.After(3 * time.Second):
223 223
 		t.Fatalf("Calling \"docker ps -s\" timed out!")
224 224
 	}
225
-	errorOut(err, t, out)
225
+	if err != nil {
226
+		t.Fatal(out, err)
227
+	}
226 228
 	lines := strings.Split(strings.Trim(out, "\n "), "\n")
227 229
 	sizeIndex := strings.Index(lines[0], "SIZE")
228 230
 	idIndex := strings.Index(lines[0], "CONTAINER ID")
... ...
@@ -247,24 +292,31 @@ func TestPsListContainersFilterStatus(t *testing.T) {
247 247
 	// start exited container
248 248
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox")
249 249
 	out, _, err := runCommandWithOutput(runCmd)
250
-	errorOut(err, t, out)
250
+	if err != nil {
251
+		t.Fatal(out, err)
252
+	}
251 253
 	firstID := stripTrailingCharacters(out)
252 254
 
253 255
 	// make sure the exited cintainer is not running
254 256
 	runCmd = exec.Command(dockerBinary, "wait", firstID)
255
-	out, _, err = runCommandWithOutput(runCmd)
256
-	errorOut(err, t, out)
257
+	if out, _, err = runCommandWithOutput(runCmd); err != nil {
258
+		t.Fatal(out, err)
259
+	}
257 260
 
258 261
 	// start running container
259 262
 	runCmd = exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 360")
260 263
 	out, _, err = runCommandWithOutput(runCmd)
261
-	errorOut(err, t, out)
264
+	if err != nil {
265
+		t.Fatal(out, err)
266
+	}
262 267
 	secondID := stripTrailingCharacters(out)
263 268
 
264 269
 	// filter containers by exited
265 270
 	runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--filter=status=exited")
266 271
 	out, _, err = runCommandWithOutput(runCmd)
267
-	errorOut(err, t, out)
272
+	if err != nil {
273
+		t.Fatal(out, err)
274
+	}
268 275
 	containerOut := strings.TrimSpace(out)
269 276
 	if containerOut != firstID[:12] {
270 277
 		t.Fatalf("Expected id %s, got %s for exited filter, output: %q", firstID[:12], containerOut, out)
... ...
@@ -272,7 +324,9 @@ func TestPsListContainersFilterStatus(t *testing.T) {
272 272
 
273 273
 	runCmd = exec.Command(dockerBinary, "ps", "-a", "-q", "--filter=status=running")
274 274
 	out, _, err = runCommandWithOutput(runCmd)
275
-	errorOut(err, t, out)
275
+	if err != nil {
276
+		t.Fatal(out, err)
277
+	}
276 278
 	containerOut = strings.TrimSpace(out)
277 279
 	if containerOut != secondID[:12] {
278 280
 		t.Fatalf("Expected id %s, got %s for running filter, output: %q", secondID[:12], containerOut, out)