github.imxd.top/hashicorp/consul@v1.4.5/api/status_test.go (about)

     1  package api
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestAPI_StatusLeader(t *testing.T) {
     8  	t.Parallel()
     9  	c, s := makeClient(t)
    10  	defer s.Stop()
    11  	s.WaitForSerfCheck(t)
    12  
    13  	status := c.Status()
    14  
    15  	leader, err := status.Leader()
    16  	if err != nil {
    17  		t.Fatalf("err: %v", err)
    18  	}
    19  	if leader == "" {
    20  		t.Fatalf("Expected leader")
    21  	}
    22  }
    23  
    24  func TestAPI_StatusPeers(t *testing.T) {
    25  	t.Parallel()
    26  	c, s := makeClient(t)
    27  	defer s.Stop()
    28  	s.WaitForSerfCheck(t)
    29  
    30  	status := c.Status()
    31  
    32  	peers, err := status.Peers()
    33  	if err != nil {
    34  		t.Fatalf("err: %v", err)
    35  	}
    36  	if len(peers) == 0 {
    37  		t.Fatalf("Expected peers ")
    38  	}
    39  }