-
Notifications
You must be signed in to change notification settings - Fork 164
/
client_options_test.go
54 lines (43 loc) · 1.23 KB
/
client_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
42
43
44
45
46
47
48
49
50
51
52
53
54
package workwx
import (
"net/http"
"testing"
c "github.com/smartystreets/goconvey/convey"
)
func TestDefaultOptions(t *testing.T) {
c.Convey("给定一个默认值 options", t, func() {
opts := defaultOptions()
c.Convey("opts.HTTP 应该是空值 http.Client", func() {
c.So(opts.HTTP, c.ShouldNotBeNil)
c.So(*opts.HTTP, c.ShouldResemble, http.Client{})
})
c.Convey("opts.QYAPIHost 应该是企业微信官方 API host", func() {
c.So(opts.QYAPIHost, c.ShouldEqual, "https://qyapi.weixin.qq.com")
})
})
}
func TestWithHTTPClient(t *testing.T) {
c.Convey("给定一个 options", t, func() {
opts := options{}
c.Convey("用 WithHTTPClient 修饰它", func() {
newClient := http.Client{}
o := WithHTTPClient(&newClient)
o.applyTo(&opts)
c.Convey("options.HTTP 应该变了", func() {
c.So(opts.HTTP, c.ShouldEqual, &newClient)
})
})
})
}
func TestWithQYAPIHost(t *testing.T) {
c.Convey("给定一个 options", t, func() {
opts := options{}
c.Convey("用 WithQYAPIHost 修饰它", func() {
o := WithQYAPIHost("http://localhost:8000")
o.applyTo(&opts)
c.Convey("options.QYAPIHost 应该变了", func() {
c.So(opts.QYAPIHost, c.ShouldEqual, "http://localhost:8000")
})
})
})
}