mirror of https://github.com/hashicorp/consul
parent
caaff11634
commit
f062e31be7
@ -0,0 +1,13 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (s *HTTPServer) CatalogDatacenters(req *http.Request) (interface{}, error) {
|
||||
var out []string
|
||||
if err := s.agent.RPC("Catalog.ListDatacenters", struct{}{}, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCatalogDatacenters(t *testing.T) {
|
||||
dir, srv := makeHTTPServer(t)
|
||||
defer os.RemoveAll(dir)
|
||||
defer srv.Shutdown()
|
||||
defer srv.agent.Shutdown()
|
||||
|
||||
obj, err := srv.CatalogDatacenters(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
|
||||
dcs := obj.([]string)
|
||||
if len(dcs) != 1 {
|
||||
t.Fatalf("bad: %v", obj)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue