github.com/DerekStrickland/consul@v1.4.5/command/connect/ca/get/connect_ca_get_test.go (about) 1 package get 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/hashicorp/consul/testrpc" 8 9 "github.com/hashicorp/consul/agent" 10 "github.com/mitchellh/cli" 11 ) 12 13 func TestConnectCAGetConfigCommand_noTabs(t *testing.T) { 14 t.Parallel() 15 if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { 16 t.Fatal("help has tabs") 17 } 18 } 19 20 func TestConnectCAGetConfigCommand(t *testing.T) { 21 t.Parallel() 22 a := agent.NewTestAgent(t, t.Name(), ``) 23 defer a.Shutdown() 24 testrpc.WaitForTestAgent(t, a.RPC, "dc1") 25 26 ui := cli.NewMockUi() 27 c := New(ui) 28 args := []string{"-http-addr=" + a.HTTPAddr()} 29 30 code := c.Run(args) 31 if code != 0 { 32 t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) 33 } 34 output := strings.TrimSpace(ui.OutputWriter.String()) 35 if !strings.Contains(output, `"Provider": "consul"`) { 36 t.Fatalf("bad: %s", output) 37 } 38 }