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