mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
8455077e5d
This is necessary as consul-api's tests require a real consul instance to be running. We can't directly import an agent to fire up an instance, due to the way this would create an import cycle. These tests instead will start a consul instance using the binary in $PATH (if it exists).
36 lines
505 B
Go
36 lines
505 B
Go
package api
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestStatusLeader(t *testing.T) {
|
|
c, s := makeClient(t)
|
|
defer s.stop()
|
|
|
|
status := c.Status()
|
|
|
|
leader, err := status.Leader()
|
|
if err != nil {
|
|
t.Fatalf("err: %v", err)
|
|
}
|
|
if leader == "" {
|
|
t.Fatalf("Expected leader")
|
|
}
|
|
}
|
|
|
|
func TestStatusPeers(t *testing.T) {
|
|
c, s := makeClient(t)
|
|
defer s.stop()
|
|
|
|
status := c.Status()
|
|
|
|
peers, err := status.Peers()
|
|
if err != nil {
|
|
t.Fatalf("err: %v", err)
|
|
}
|
|
if len(peers) == 0 {
|
|
t.Fatalf("Expected peers ")
|
|
}
|
|
}
|