File tree 2 files changed +48
-20
lines changed
2 files changed +48
-20
lines changed Original file line number Diff line number Diff line change @@ -68,42 +68,22 @@ func New(authToken string, setters ...APISetting) *API {
68
68
}
69
69
70
70
func (c * API ) Users () UsersInterface {
71
- if c == nil {
72
- return nil
73
- }
74
-
75
71
return c .usersClient
76
72
}
77
73
78
74
func (c * API ) Databases () DatabasesInterface {
79
- if c == nil {
80
- return nil
81
- }
82
-
83
75
return c .databasesClient
84
76
}
85
77
86
78
func (c * API ) Pages () PagesInterface {
87
- if c == nil {
88
- return nil
89
- }
90
-
91
79
return c .pagesClient
92
80
}
93
81
94
82
func (c * API ) Blocks () BlocksInterface {
95
- if c == nil {
96
- return nil
97
- }
98
-
99
83
return c .blocksClient
100
84
}
101
85
102
86
func (c * API ) Search (ctx context.Context , params SearchParameters ) (* SearchResponse , error ) {
103
- if c == nil {
104
- return nil , ErrUnknown
105
- }
106
-
107
87
return c .searchClient .Search (ctx , params )
108
88
}
109
89
Original file line number Diff line number Diff line change
1
+ package notion
2
+
3
+ import (
4
+ "net/http"
5
+ "testing"
6
+
7
+ "github.com/stretchr/testify/assert"
8
+ )
9
+
10
+ func TestWithUserAgent (t * testing.T ) {
11
+ var settings apiSettings
12
+
13
+ userAgent := "test-user-agent"
14
+
15
+ WithUserAgent ("test-user-agent" )(& settings )
16
+
17
+ assert .Equal (t , settings .userAgent , userAgent )
18
+ }
19
+
20
+ func TestWithBaseURL (t * testing.T ) {
21
+ var settings apiSettings
22
+
23
+ baseURL := "https://example.com"
24
+
25
+ WithBaseURL (baseURL )(& settings )
26
+
27
+ assert .Equal (t , settings .baseURL , baseURL )
28
+ }
29
+
30
+ func TestNotionVersion (t * testing.T ) {
31
+ var settings apiSettings
32
+
33
+ notionVersion := "2021-05-19"
34
+
35
+ WithNotionVersion (notionVersion )(& settings )
36
+
37
+ assert .Equal (t , settings .notionVersion , notionVersion )
38
+ }
39
+
40
+ func TestHTTPClient (t * testing.T ) {
41
+ var settings apiSettings
42
+
43
+ httpClient := & http.Client {}
44
+
45
+ WithHTTPClient (httpClient )(& settings )
46
+
47
+ assert .Same (t , settings .httpClient , httpClient )
48
+ }
You can’t perform that action at this time.
0 commit comments