Browse code

Cleanup errorOut resp in create test

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

Jessica Frazelle authored on 2014/10/15 04:34:02
Showing 1 changed files
... ...
@@ -2,7 +2,6 @@ package main
2 2
 
3 3
 import (
4 4
 	"encoding/json"
5
-	"fmt"
6 5
 	"os/exec"
7 6
 	"testing"
8 7
 	"time"
... ...
@@ -12,13 +11,17 @@ import (
12 12
 func TestCreateArgs(t *testing.T) {
13 13
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "command", "arg1", "arg2", "arg with space")
14 14
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
15
-	errorOut(err, t, out)
15
+	if err != nil {
16
+		t.Fatal(out, err)
17
+	}
16 18
 
17 19
 	cleanedContainerID := stripTrailingCharacters(out)
18 20
 
19 21
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
20
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
21
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
22
+	out, _, err = runCommandWithOutput(inspectCmd)
23
+	if err != nil {
24
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
25
+	}
22 26
 
23 27
 	containers := []struct {
24 28
 		ID      string
... ...
@@ -27,7 +30,7 @@ func TestCreateArgs(t *testing.T) {
27 27
 		Args    []string
28 28
 		Image   string
29 29
 	}{}
30
-	if err := json.Unmarshal([]byte(inspectOut), &containers); err != nil {
30
+	if err := json.Unmarshal([]byte(out), &containers); err != nil {
31 31
 		t.Fatalf("Error inspecting the container: %s", err)
32 32
 	}
33 33
 	if len(containers) != 1 {
... ...
@@ -60,20 +63,24 @@ func TestCreateArgs(t *testing.T) {
60 60
 func TestCreateHostConfig(t *testing.T) {
61 61
 	runCmd := exec.Command(dockerBinary, "create", "-P", "busybox", "echo")
62 62
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
63
-	errorOut(err, t, out)
63
+	if err != nil {
64
+		t.Fatal(out, err)
65
+	}
64 66
 
65 67
 	cleanedContainerID := stripTrailingCharacters(out)
66 68
 
67 69
 	inspectCmd := exec.Command(dockerBinary, "inspect", cleanedContainerID)
68
-	inspectOut, _, err := runCommandWithOutput(inspectCmd)
69
-	errorOut(err, t, fmt.Sprintf("out should've been a container id: %v %v", inspectOut, err))
70
+	out, _, err = runCommandWithOutput(inspectCmd)
71
+	if err != nil {
72
+		t.Fatalf("out should've been a container id: %s, %v", out, err)
73
+	}
70 74
 
71 75
 	containers := []struct {
72 76
 		HostConfig *struct {
73 77
 			PublishAllPorts bool
74 78
 		}
75 79
 	}{}
76
-	if err := json.Unmarshal([]byte(inspectOut), &containers); err != nil {
80
+	if err := json.Unmarshal([]byte(out), &containers); err != nil {
77 81
 		t.Fatalf("Error inspecting the container: %s", err)
78 82
 	}
79 83
 	if len(containers) != 1 {
... ...
@@ -98,13 +105,17 @@ func TestCreateHostConfig(t *testing.T) {
98 98
 func TestCreateEchoStdout(t *testing.T) {
99 99
 	runCmd := exec.Command(dockerBinary, "create", "busybox", "echo", "test123")
100 100
 	out, _, _, err := runCommandWithStdoutStderr(runCmd)
101
-	errorOut(err, t, out)
101
+	if err != nil {
102
+		t.Fatal(out, err)
103
+	}
102 104
 
103 105
 	cleanedContainerID := stripTrailingCharacters(out)
104 106
 
105 107
 	runCmd = exec.Command(dockerBinary, "start", "-ai", cleanedContainerID)
106 108
 	out, _, _, err = runCommandWithStdoutStderr(runCmd)
107
-	errorOut(err, t, out)
109
+	if err != nil {
110
+		t.Fatal(out, err)
111
+	}
108 112
 
109 113
 	if out != "test123\n" {
110 114
 		t.Errorf("container should've printed 'test123', got %q", out)