33 lines
787 B
Go
33 lines
787 B
Go
package command
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/mitchellh/cli"
|
|
)
|
|
|
|
func TestOperator_Raft_RemovePeers_Implements(t *testing.T) {
|
|
var _ cli.Command = &OperatorRaftRemoveCommand{}
|
|
}
|
|
|
|
func TestOperator_Raft_RemovePeer(t *testing.T) {
|
|
s, _, addr := testServer(t, nil)
|
|
defer s.Stop()
|
|
|
|
ui := new(cli.MockUi)
|
|
c := &OperatorRaftRemoveCommand{Meta: Meta{Ui: ui}}
|
|
args := []string{"-address=" + addr, "-peer-address=nope"}
|
|
|
|
code := c.Run(args)
|
|
if code != 1 {
|
|
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
|
|
}
|
|
|
|
// If we get this error, it proves we sent the address all they through.
|
|
output := strings.TrimSpace(ui.ErrorWriter.String())
|
|
if !strings.Contains(output, "address \"nope\" was not found in the Raft configuration") {
|
|
t.Fatalf("bad: %s", output)
|
|
}
|
|
}
|