Browse code

refactor docker_cli_proxy_test.go part of #16756

Signed-off-by: Xiaoxu Chen <chenxiaoxu14@otcaix.iscas.ac.cn>

Xiaoxu Chen authored on 2015/10/09 12:11:05
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"os/exec"
6 6
 	"strings"
7 7
 
8
+	"github.com/docker/docker/pkg/integration/checker"
8 9
 	"github.com/go-check/check"
9 10
 )
10 11
 
... ...
@@ -15,9 +16,8 @@ func (s *DockerSuite) TestCliProxyDisableProxyUnixSock(c *check.C) {
15 15
 	cmd := exec.Command(dockerBinary, "info")
16 16
 	cmd.Env = appendBaseEnv([]string{"HTTP_PROXY=http://127.0.0.1:9999"})
17 17
 
18
-	if out, _, err := runCommandWithOutput(cmd); err != nil {
19
-		c.Fatal(err, out)
20
-	}
18
+	out, _, err := runCommandWithOutput(cmd)
19
+	c.Assert(err, checker.IsNil, check.Commentf("%v", out))
21 20
 
22 21
 }
23 22
 
... ...
@@ -27,9 +27,7 @@ func (s *DockerDaemonSuite) TestCliProxyProxyTCPSock(c *check.C) {
27 27
 	testRequires(c, SameHostDaemon)
28 28
 	// get the IP to use to connect since we can't use localhost
29 29
 	addrs, err := net.InterfaceAddrs()
30
-	if err != nil {
31
-		c.Fatal(err)
32
-	}
30
+	c.Assert(err, checker.IsNil)
33 31
 	var ip string
34 32
 	for _, addr := range addrs {
35 33
 		sAddr := addr.String()
... ...
@@ -40,24 +38,15 @@ func (s *DockerDaemonSuite) TestCliProxyProxyTCPSock(c *check.C) {
40 40
 		}
41 41
 	}
42 42
 
43
-	if ip == "" {
44
-		c.Fatal("could not find ip to connect to")
45
-	}
46
-
47
-	if err := s.d.Start("-H", "tcp://"+ip+":2375"); err != nil {
48
-		c.Fatal(err)
49
-	}
50
-
43
+	c.Assert(ip, checker.Equals, "")
44
+	err = s.d.Start("-H", "tcp://"+ip+":2375")
45
+	c.Assert(err, checker.IsNil)
51 46
 	cmd := exec.Command(dockerBinary, "info")
52 47
 	cmd.Env = []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"}
53
-	if out, _, err := runCommandWithOutput(cmd); err == nil {
54
-		c.Fatal(err, out)
55
-	}
56
-
48
+	out, _, err := runCommandWithOutput(cmd)
49
+	c.Assert(err, checker.NotNil, check.Commentf("%v", out))
57 50
 	// Test with no_proxy
58 51
 	cmd.Env = append(cmd.Env, "NO_PROXY="+ip)
59
-	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "info")); err != nil {
60
-		c.Fatal(err, out)
61
-	}
62
-
52
+	out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "info"))
53
+	c.Assert(err, checker.IsNil, check.Commentf("%v", out))
63 54
 }