github.com/djenriquez/nomad-1@v0.8.1/api/operator_test.go (about) 1 package api 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 func TestOperator_RaftGetConfiguration(t *testing.T) { 9 t.Parallel() 10 c, s := makeClient(t, nil, nil) 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 TestOperator_RaftRemovePeerByAddress(t *testing.T) { 26 t.Parallel() 27 c, s := makeClient(t, nil, nil) 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 } 39 40 func TestOperator_RaftRemovePeerByID(t *testing.T) { 41 t.Parallel() 42 c, s := makeClient(t, nil, nil) 43 defer s.Stop() 44 45 // If we get this error, it proves we sent the address all the way 46 // through. 47 operator := c.Operator() 48 err := operator.RaftRemovePeerByID("nope", nil) 49 if err == nil || !strings.Contains(err.Error(), 50 "id \"nope\" was not found in the Raft configuration") { 51 t.Fatalf("err: %v", err) 52 } 53 }