github.com/hernad/nomad@v1.6.112/command/agent/region_endpoint_test.go (about)

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