2018-05-23 21:44:41 +00:00
|
|
|
package get
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2018-09-12 13:49:27 +00:00
|
|
|
"github.com/hashicorp/consul/testrpc"
|
|
|
|
|
2018-05-23 21:44:41 +00:00
|
|
|
"github.com/hashicorp/consul/agent"
|
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConnectCAGetConfigCommand_noTabs(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') {
|
|
|
|
t.Fatal("help has tabs")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConnectCAGetConfigCommand(t *testing.T) {
|
|
|
|
t.Parallel()
|
2019-02-14 15:59:14 +00:00
|
|
|
a := agent.NewTestAgent(t, t.Name(), ``)
|
2018-05-23 21:44:41 +00:00
|
|
|
defer a.Shutdown()
|
2018-09-12 13:49:27 +00:00
|
|
|
testrpc.WaitForTestAgent(t, a.RPC, "dc1")
|
2018-05-23 21:44:41 +00:00
|
|
|
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
args := []string{"-http-addr=" + a.HTTPAddr()}
|
|
|
|
|
|
|
|
code := c.Run(args)
|
|
|
|
if code != 0 {
|
|
|
|
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
|
|
|
|
}
|
|
|
|
output := strings.TrimSpace(ui.OutputWriter.String())
|
|
|
|
if !strings.Contains(output, `"Provider": "consul"`) {
|
|
|
|
t.Fatalf("bad: %s", output)
|
|
|
|
}
|
|
|
|
}
|