From 1bb4b9511042356afc3af2fbee9095e5f441d75e Mon Sep 17 00:00:00 2001 From: Ke Zhu Date: Fri, 6 Mar 2015 14:23:16 -0500 Subject: [PATCH] keep using --tlsverify between config and env commands Signed-off-by: Ke Zhu --- commands.go | 2 +- commands_test.go | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/commands.go b/commands.go index 384f436768..f755084a5e 100644 --- a/commands.go +++ b/commands.go @@ -369,7 +369,7 @@ func cmdConfig(c *cli.Context) { dockerHost = fmt.Sprintf("tcp://%s:%s", machineIp, swarmPort) } - fmt.Printf("--tls --tlscacert=%s --tlscert=%s --tlskey=%s -H=%s", + fmt.Printf("--tlsverify --tlscacert=%s --tlscert=%s --tlskey=%s -H=%s", cfg.caCertPath, cfg.clientCertPath, cfg.clientKeyPath, dockerHost) } diff --git a/commands_test.go b/commands_test.go index 51651a276f..ce875bec1e 100644 --- a/commands_test.go +++ b/commands_test.go @@ -300,14 +300,13 @@ func TestRunActionForeachMachine(t *testing.T) { func TestCmdConfig(t *testing.T) { stdout := os.Stdout r, w, _ := os.Pipe() - os.Stdout = w + os.Stdout = w os.Setenv("MACHINE_STORAGE_PATH", TestStoreDir) defer func() { os.Setenv("MACHINE_STORAGE_PATH", "") os.Stdout = stdout - w.Close() }() if err := clearHosts(); err != nil { @@ -333,17 +332,27 @@ func TestCmdConfig(t *testing.T) { t.Fatalf("error setting active host: %v", err) } + outStr := make(chan string) + + go func() { + var testOutput bytes.Buffer + io.Copy(&testOutput, r) + outStr <- testOutput.String() + }() + set := flag.NewFlagSet("config", 0) - - testOutput := &bytes.Buffer{} - - go io.Copy(testOutput, r) - c := cli.NewContext(nil, set, set) - cmdConfig(c) - if strings.Contains(testOutput.String(), "-H=unix:///var/run/docker.sock") { + w.Close() + + out := <-outStr + + if !strings.Contains(out, "--tlsverify") { + t.Fatalf("Expect --tlsverify") + } + + if !strings.Contains(out, "-H=unix:///var/run/docker.sock") { t.Fatalf("Expect docker host URL") } }