You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/agent/status_endpoint_test.go

40 lines
720 B

package agent
import (
"net/http"
"testing"
)
func TestStatusLeader(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
req, _ := http.NewRequest("GET", "/v1/status/leader", nil)
obj, err := a.srv.StatusLeader(nil, req)
if err != nil {
t.Fatalf("Err: %v", err)
}
val := obj.(string)
if val == "" {
t.Fatalf("bad addr: %v", obj)
}
}
func TestStatusPeers(t *testing.T) {
t.Parallel()
a := NewTestAgent(t.Name(), "")
defer a.Shutdown()
req, _ := http.NewRequest("GET", "/v1/status/peers", nil)
obj, err := a.srv.StatusPeers(nil, req)
if err != nil {
t.Fatalf("Err: %v", err)
}
peers := obj.([]string)
if len(peers) != 1 {
t.Fatalf("bad peers: %v", peers)
}
}