github.com/hernad/nomad@v1.6.112/command/operator_raft_list_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package command 5 6 import ( 7 "strings" 8 "testing" 9 10 "github.com/hernad/nomad/ci" 11 "github.com/mitchellh/cli" 12 ) 13 14 func TestOperator_Raft_ListPeers_Implements(t *testing.T) { 15 ci.Parallel(t) 16 var _ cli.Command = &OperatorRaftListCommand{} 17 } 18 19 func TestOperator_Raft_ListPeers(t *testing.T) { 20 ci.Parallel(t) 21 s, _, addr := testServer(t, false, nil) 22 defer s.Shutdown() 23 24 ui := cli.NewMockUi() 25 c := &OperatorRaftListCommand{Meta: Meta{Ui: ui}} 26 args := []string{"-address=" + addr} 27 28 code := c.Run(args) 29 if code != 0 { 30 t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String()) 31 } 32 output := strings.TrimSpace(ui.OutputWriter.String()) 33 if !strings.Contains(output, "leader") { 34 t.Fatalf("bad: %s", output) 35 } 36 }