-
Notifications
You must be signed in to change notification settings - Fork 1
/
options_test.go
41 lines (37 loc) · 960 Bytes
/
options_test.go
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
36
37
38
39
40
41
package modzy
import (
"net/http"
"testing"
)
func TestClientOptionWithHTTPClient(t *testing.T) {
client := &standardClient{
requestor: &requestor{},
}
httpClient := &http.Client{}
WithHTTPClient(httpClient)(client)
if client.requestor.httpClient != httpClient {
t.Errorf("Option did not set httpClient")
}
}
func TestClientOptionWithHTTPDebugging(t *testing.T) {
client := &standardClient{
requestor: &requestor{},
}
WithHTTPDebugging(true, false)(client)
if !client.requestor.requestDebugging {
t.Errorf("Expected requestDebugging to be true")
}
if client.requestor.responseDebugging {
t.Errorf("Expected responseDebugging to be false")
}
client = &standardClient{
requestor: &requestor{},
}
WithHTTPDebugging(false, true)(client)
if client.requestor.requestDebugging {
t.Errorf("Expected requestDebugging to be false")
}
if !client.requestor.responseDebugging {
t.Errorf("Expected requestDebugging to be true")
}
}