github.com/DerekStrickland/consul@v1.4.5/command/info/info_test.go (about)

     1  package info
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/hashicorp/consul/agent"
     8  	"github.com/mitchellh/cli"
     9  )
    10  
    11  func TestInfoCommand_noTabs(t *testing.T) {
    12  	t.Parallel()
    13  	if strings.ContainsRune(New(nil).Help(), '\t') {
    14  		t.Fatal("help has tabs")
    15  	}
    16  }
    17  
    18  func TestInfoCommand(t *testing.T) {
    19  	t.Parallel()
    20  	a1 := agent.NewTestAgent(t, t.Name(), ``)
    21  	defer a1.Shutdown()
    22  
    23  	ui := cli.NewMockUi()
    24  	cmd := New(ui)
    25  	args := []string{"-http-addr=" + a1.HTTPAddr()}
    26  
    27  	code := cmd.Run(args)
    28  	if code != 0 {
    29  		t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
    30  	}
    31  
    32  	if !strings.Contains(ui.OutputWriter.String(), "agent") {
    33  		t.Fatalf("bad: %#v", ui.OutputWriter.String())
    34  	}
    35  }