github.com/blixtra/nomad@v0.7.2-0.20171221000451-da9a1d7bb050/command/operator_raft_remove_test.go (about)

     1  package command
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/mitchellh/cli"
     8  )
     9  
    10  func TestOperator_Raft_RemovePeers_Implements(t *testing.T) {
    11  	t.Parallel()
    12  	var _ cli.Command = &OperatorRaftRemoveCommand{}
    13  }
    14  
    15  func TestOperator_Raft_RemovePeer(t *testing.T) {
    16  	t.Parallel()
    17  	s, _, addr := testServer(t, false, nil)
    18  	defer s.Shutdown()
    19  
    20  	ui := new(cli.MockUi)
    21  	c := &OperatorRaftRemoveCommand{Meta: Meta{Ui: ui}}
    22  	args := []string{"-address=" + addr, "-peer-address=nope"}
    23  
    24  	code := c.Run(args)
    25  	if code != 1 {
    26  		t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
    27  	}
    28  
    29  	// If we get this error, it proves we sent the address all they through.
    30  	output := strings.TrimSpace(ui.ErrorWriter.String())
    31  	if !strings.Contains(output, "address \"nope\" was not found in the Raft configuration") {
    32  		t.Fatalf("bad: %s", output)
    33  	}
    34  }