github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/testing/service_client_test.go (about) 1 package testing 2 3 import ( 4 "context" 5 "fmt" 6 "net/http" 7 "testing" 8 9 "github.com/vnpaycloud-console/gophercloud/v2" 10 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 11 ) 12 13 func TestServiceURL(t *testing.T) { 14 c := &gophercloud.ServiceClient{Endpoint: "http://123.45.67.8/"} 15 expected := "http://123.45.67.8/more/parts/here" 16 actual := c.ServiceURL("more", "parts", "here") 17 th.CheckEquals(t, expected, actual) 18 } 19 20 func TestMoreHeaders(t *testing.T) { 21 th.SetupHTTP() 22 defer th.TeardownHTTP() 23 th.Mux.HandleFunc("/route", func(w http.ResponseWriter, r *http.Request) { 24 w.WriteHeader(http.StatusOK) 25 }) 26 27 c := new(gophercloud.ServiceClient) 28 c.MoreHeaders = map[string]string{ 29 "custom": "header", 30 } 31 c.ProviderClient = new(gophercloud.ProviderClient) 32 resp, err := c.Get(context.TODO(), fmt.Sprintf("%s/route", th.Endpoint()), nil, nil) 33 th.AssertNoErr(t, err) 34 th.AssertEquals(t, resp.Request.Header.Get("custom"), "header") 35 }