forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice_client_test.go
More file actions
35 lines (30 loc) · 959 Bytes
/
service_client_test.go
File metadata and controls
35 lines (30 loc) · 959 Bytes
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
35
package testing
import (
"context"
"fmt"
"net/http"
"testing"
"github.com/gophercloud/gophercloud/v2"
th "github.com/gophercloud/gophercloud/v2/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) {
fakeServer := th.SetupHTTP()
defer fakeServer.Teardown()
fakeServer.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(context.TODO(), fmt.Sprintf("%s/route", fakeServer.Endpoint()), nil, nil)
th.AssertNoErr(t, err)
th.AssertEquals(t, resp.Request.Header.Get("custom"), "header")
}