From 14f43406a38b1f66ab60b5235bde4b0121eed093 Mon Sep 17 00:00:00 2001 From: Xiaoxu Chen Date: Fri, 9 Oct 2015 11:11:05 +0800 Subject: [PATCH 1/2] refactor docker_cli_proxy_test.go part of #16756 Signed-off-by: Xiaoxu Chen --- integration-cli/docker_cli_proxy_test.go | 33 ++++++++---------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/integration-cli/docker_cli_proxy_test.go b/integration-cli/docker_cli_proxy_test.go index ec16290ce5..b804075b8c 100644 --- a/integration-cli/docker_cli_proxy_test.go +++ b/integration-cli/docker_cli_proxy_test.go @@ -5,6 +5,7 @@ import ( "os/exec" "strings" + "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) @@ -15,9 +16,8 @@ func (s *DockerSuite) TestCliProxyDisableProxyUnixSock(c *check.C) { cmd := exec.Command(dockerBinary, "info") cmd.Env = appendBaseEnv([]string{"HTTP_PROXY=http://127.0.0.1:9999"}) - if out, _, err := runCommandWithOutput(cmd); err != nil { - c.Fatal(err, out) - } + out, _, err := runCommandWithOutput(cmd) + c.Assert(err, checker.IsNil, check.Commentf("%v", out)) } @@ -27,9 +27,7 @@ func (s *DockerDaemonSuite) TestCliProxyProxyTCPSock(c *check.C) { testRequires(c, SameHostDaemon) // get the IP to use to connect since we can't use localhost addrs, err := net.InterfaceAddrs() - if err != nil { - c.Fatal(err) - } + c.Assert(err, checker.IsNil) var ip string for _, addr := range addrs { sAddr := addr.String() @@ -40,24 +38,15 @@ func (s *DockerDaemonSuite) TestCliProxyProxyTCPSock(c *check.C) { } } - if ip == "" { - c.Fatal("could not find ip to connect to") - } - - if err := s.d.Start("-H", "tcp://"+ip+":2375"); err != nil { - c.Fatal(err) - } - + c.Assert(ip, checker.Equals, "") + err = s.d.Start("-H", "tcp://"+ip+":2375") + c.Assert(err, checker.IsNil) cmd := exec.Command(dockerBinary, "info") cmd.Env = []string{"DOCKER_HOST=tcp://" + ip + ":2375", "HTTP_PROXY=127.0.0.1:9999"} - if out, _, err := runCommandWithOutput(cmd); err == nil { - c.Fatal(err, out) - } - + out, _, err := runCommandWithOutput(cmd) + c.Assert(err, checker.NotNil, check.Commentf("%v", out)) // Test with no_proxy cmd.Env = append(cmd.Env, "NO_PROXY="+ip) - if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "info")); err != nil { - c.Fatal(err, out) - } - + out, _, err = runCommandWithOutput(exec.Command(dockerBinary, "info")) + c.Assert(err, checker.IsNil, check.Commentf("%v", out)) } From 1db161768ccfc67d36034f06db36451b6cc6a214 Mon Sep 17 00:00:00 2001 From: Xiaoxu Chen Date: Fri, 9 Oct 2015 14:53:56 +0800 Subject: [PATCH 2/2] update docker_cli_proxy_test.go Part of #16756 Signed-off-by: Xiaoxu Chen --- integration-cli/docker_cli_proxy_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-cli/docker_cli_proxy_test.go b/integration-cli/docker_cli_proxy_test.go index b804075b8c..e0b60fcc59 100644 --- a/integration-cli/docker_cli_proxy_test.go +++ b/integration-cli/docker_cli_proxy_test.go @@ -38,7 +38,8 @@ func (s *DockerDaemonSuite) TestCliProxyProxyTCPSock(c *check.C) { } } - c.Assert(ip, checker.Equals, "") + c.Assert(ip, checker.Not(checker.Equals), "") + err = s.d.Start("-H", "tcp://"+ip+":2375") c.Assert(err, checker.IsNil) cmd := exec.Command(dockerBinary, "info")