github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/command/agent/region_endpoint_test.go (about)

     1  package agent
     2  
     3  import (
     4  	"net/http"
     5  	"net/http/httptest"
     6  	"testing"
     7  )
     8  
     9  func TestHTTP_RegionList(t *testing.T) {
    10  	t.Parallel()
    11  	httpTest(t, nil, func(s *TestAgent) {
    12  		// Make the HTTP request
    13  		req, err := http.NewRequest("GET", "/v1/regions", nil)
    14  		if err != nil {
    15  			t.Fatalf("err: %v", err)
    16  		}
    17  		respW := httptest.NewRecorder()
    18  
    19  		// Make the request
    20  		obj, err := s.Server.RegionListRequest(respW, req)
    21  		if err != nil {
    22  			t.Fatalf("err: %v", err)
    23  		}
    24  
    25  		out := obj.([]string)
    26  		if len(out) != 1 || out[0] != "global" {
    27  			t.Fatalf("unexpected regions: %#v", out)
    28  		}
    29  	})
    30  }