github.com/ncodes/nomad@v0.5.7-0.20170403112158-97adf4a74fb3/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  	c, s := makeClient(t, nil, nil)
    10  	defer s.Stop()
    11  
    12  	operator := c.Operator()
    13  	out, err := operator.RaftGetConfiguration(nil)
    14  	if err != nil {
    15  		t.Fatalf("err: %v", err)
    16  	}
    17  	if len(out.Servers) != 1 ||
    18  		!out.Servers[0].Leader ||
    19  		!out.Servers[0].Voter {
    20  		t.Fatalf("bad: %v", out)
    21  	}
    22  }
    23  
    24  func TestOperator_RaftRemovePeerByAddress(t *testing.T) {
    25  	c, s := makeClient(t, nil, nil)
    26  	defer s.Stop()
    27  
    28  	// If we get this error, it proves we sent the address all the way
    29  	// through.
    30  	operator := c.Operator()
    31  	err := operator.RaftRemovePeerByAddress("nope", nil)
    32  	if err == nil || !strings.Contains(err.Error(),
    33  		"address \"nope\" was not found in the Raft configuration") {
    34  		t.Fatalf("err: %v", err)
    35  	}
    36  }