2015-11-24 06:22:48 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
2022-03-15 12:42:43 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
2015-11-24 06:22:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestHTTP_RegionList(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
2017-07-20 05:14:36 +00:00
|
|
|
httpTest(t, nil, func(s *TestAgent) {
|
2015-11-24 06:22:48 +00:00
|
|
|
// Make the HTTP request
|
|
|
|
req, err := http.NewRequest("GET", "/v1/regions", nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
respW := httptest.NewRecorder()
|
|
|
|
|
|
|
|
// Make the request
|
|
|
|
obj, err := s.Server.RegionListRequest(respW, req)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("err: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
out := obj.([]string)
|
|
|
|
if len(out) != 1 || out[0] != "global" {
|
|
|
|
t.Fatalf("unexpected regions: %#v", out)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|