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