mirror of
https://github.com/status-im/consul.git
synced 2025-02-13 14:16:35 +00:00
This patch removes duplicate internal copies of constants in the structs package which are also defined in the api package. The api.KVOp type with all its values for the TXN endpoint and the api.HealthXXX constants are now used throughout the codebase. This resulted in some circular dependencies in the testutil package which have been resolved by copying code and constants and moving the WaitForLeader function into a separate testrpc package.
44 lines
758 B
Go
44 lines
758 B
Go
package agent
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/consul/testrpc"
|
|
)
|
|
|
|
func TestStatusLeader(t *testing.T) {
|
|
dir, srv := makeHTTPServer(t)
|
|
defer os.RemoveAll(dir)
|
|
defer srv.Shutdown()
|
|
defer srv.agent.Shutdown()
|
|
|
|
testrpc.WaitForLeader(t, srv.agent.RPC, "dc1")
|
|
|
|
obj, err := srv.StatusLeader(nil, nil)
|
|
if err != nil {
|
|
t.Fatalf("Err: %v", err)
|
|
}
|
|
val := obj.(string)
|
|
if val == "" {
|
|
t.Fatalf("bad addr: %v", obj)
|
|
}
|
|
}
|
|
|
|
func TestStatusPeers(t *testing.T) {
|
|
dir, srv := makeHTTPServer(t)
|
|
defer os.RemoveAll(dir)
|
|
defer srv.Shutdown()
|
|
defer srv.agent.Shutdown()
|
|
|
|
obj, err := srv.StatusPeers(nil, nil)
|
|
if err != nil {
|
|
t.Fatalf("Err: %v", err)
|
|
}
|
|
|
|
peers := obj.([]string)
|
|
if len(peers) != 1 {
|
|
t.Fatalf("bad peers: %v", peers)
|
|
}
|
|
}
|