Browse code

Cleanup errorOut resp in kill test

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

Jessica Frazelle authored on 2014/10/15 04:44:29
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,21 +9,27 @@ import (
10 10
 func TestKillContainer(t *testing.T) {
11 11
 	runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", "sleep 10")
12 12
 	out, _, err := runCommandWithOutput(runCmd)
13
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
13
+	if err != nil {
14
+		t.Fatal(out, err)
15
+	}
14 16
 
15 17
 	cleanedContainerID := stripTrailingCharacters(out)
16 18
 
17 19
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
18
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
19
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
20
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
21
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
22
+	}
20 23
 
21 24
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
22
-	out, _, err = runCommandWithOutput(killCmd)
23
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v %v", out, err))
25
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
26
+		t.Fatalf("failed to kill container: %s, %v", out, err)
27
+	}
24 28
 
25 29
 	listRunningContainersCmd := exec.Command(dockerBinary, "ps", "-q")
26 30
 	out, _, err = runCommandWithOutput(listRunningContainersCmd)
27
-	errorOut(err, t, fmt.Sprintf("failed to list running containers: %v", err))
31
+	if err != nil {
32
+		t.Fatalf("failed to list running containers: %s, %v", out, err)
33
+	}
28 34
 
29 35
 	if strings.Contains(out, cleanedContainerID) {
30 36
 		t.Fatal("killed container is still running")
... ...
@@ -38,21 +43,27 @@ func TestKillContainer(t *testing.T) {
38 38
 func TestKillDifferentUserContainer(t *testing.T) {
39 39
 	runCmd := exec.Command(dockerBinary, "run", "-u", "daemon", "-d", "busybox", "sh", "-c", "sleep 10")
40 40
 	out, _, err := runCommandWithOutput(runCmd)
41
-	errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
41
+	if err != nil {
42
+		t.Fatal(out, err)
43
+	}
42 44
 
43 45
 	cleanedContainerID := stripTrailingCharacters(out)
44 46
 
45 47
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
46
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
47
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
48
+	if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
49
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
50
+	}
48 51
 
49 52
 	killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
50
-	out, _, err = runCommandWithOutput(killCmd)
51
-	errorOut(err, t, fmt.Sprintf("failed to kill container: %v %v", out, err))
53
+	if out, _, err = runCommandWithOutput(killCmd); err != nil {
54
+		t.Fatalf("failed to kill container: %s, %v", out, err)
55
+	}
52 56
 
53 57
 	listRunningContainersCmd := exec.Command(dockerBinary, "ps", "-q")
54 58
 	out, _, err = runCommandWithOutput(listRunningContainersCmd)
55
-	errorOut(err, t, fmt.Sprintf("failed to list running containers: %v", err))
59
+	if err != nil {
60
+		t.Fatalf("failed to list running containers: %s, %v", out, err)
61
+	}
56 62
 
57 63
 	if strings.Contains(out, cleanedContainerID) {
58 64
 		t.Fatal("killed container is still running")