2015-01-06 10:40:00 -08:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2017-06-30 22:58:55 +02:00
|
|
|
func TestAPI_StatusLeader(t *testing.T) {
|
2015-05-08 10:27:24 -07:00
|
|
|
t.Parallel()
|
2015-01-06 15:26:50 -08:00
|
|
|
c, s := makeClient(t)
|
2015-03-02 18:18:38 -08:00
|
|
|
defer s.Stop()
|
2018-12-12 21:09:42 +01:00
|
|
|
s.WaitForSerfCheck(t)
|
2015-01-06 15:26:50 -08:00
|
|
|
|
2015-01-06 10:40:00 -08:00
|
|
|
status := c.Status()
|
|
|
|
|
|
|
|
leader, err := status.Leader()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if leader == "" {
|
|
|
|
t.Fatalf("Expected leader")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-30 22:58:55 +02:00
|
|
|
func TestAPI_StatusPeers(t *testing.T) {
|
2015-05-08 10:27:24 -07:00
|
|
|
t.Parallel()
|
2015-01-06 15:26:50 -08:00
|
|
|
c, s := makeClient(t)
|
2015-03-02 18:18:38 -08:00
|
|
|
defer s.Stop()
|
2018-12-12 21:09:42 +01:00
|
|
|
s.WaitForSerfCheck(t)
|
2015-01-06 15:26:50 -08:00
|
|
|
|
2015-01-06 10:40:00 -08:00
|
|
|
status := c.Status()
|
|
|
|
|
|
|
|
peers, err := status.Peers()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
if len(peers) == 0 {
|
|
|
|
t.Fatalf("Expected peers ")
|
|
|
|
}
|
|
|
|
}
|