github.imxd.top/hashicorp/consul@v1.4.5/api/operator_raft_test.go (about) 1 package api 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestAPI_OperatorRaftGetConfiguration(t *testing.T) { 9 t.Parallel() 10 c, s := makeClient(t) 11 defer s.Stop() 12 13 operator := c.Operator() 14 out, err := operator.RaftGetConfiguration(nil) 15 if err != nil { 16 t.Fatalf("err: %v", err) 17 } 18 if len(out.Servers) != 1 || 19 !out.Servers[0].Leader || 20 !out.Servers[0].Voter { 21 t.Fatalf("bad: %v", out) 22 } 23 } 24 25 func TestAPI_OperatorRaftRemovePeerByAddress(t *testing.T) { 26 t.Parallel() 27 c, s := makeClient(t) 28 defer s.Stop() 29 30 // If we get this error, it proves we sent the address all the way 31 // through. 32 operator := c.Operator() 33 err := operator.RaftRemovePeerByAddress("nope", nil) 34 if err == nil || !strings.Contains(err.Error(), 35 "address \"nope\" was not found in the Raft configuration") { 36 t.Fatalf("err: %v", err) 37 } 38 }