forked from jomei/notionapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search_test.go
48 lines (42 loc) · 997 Bytes
/
search_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
package notionapi_test
import (
"context"
"github.com/jomei/notionapi"
"net/http"
"testing"
)
func TestSearchClient(t *testing.T) {
t.Run("Do", func(t *testing.T) {
tests := []struct {
name string
filePath string
statusCode int
request *notionapi.SearchRequest
wantErr bool
err error
}{
{
name: "returns search result",
filePath: "testdata/search.json",
statusCode: http.StatusOK,
request: ¬ionapi.SearchRequest{
Query: "Hel",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := newMockedClient(t, tt.filePath, tt.statusCode)
client := notionapi.NewClient("some_token", notionapi.WithHTTPClient(c))
got, err := client.Search.Do(context.Background(), tt.request)
if (err != nil) != tt.wantErr {
t.Errorf("Do() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got == nil {
t.Errorf("Search result is nil")
}
})
}
})
}