-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_test.go
51 lines (45 loc) · 1.14 KB
/
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
49
50
51
package confluentcloud
import (
"github.com/stretchr/testify/assert"
"net/url"
"reflect"
"testing"
)
func Test_api_GetSearchContentResults(t *testing.T) {
server := confluenceRestAPIStub()
defer server.Close()
api, err := NewAPI(server.URL+"/wiki/rest/api", "username", "token")
assert.Nil(t, err)
s, err := api.GetSearchContentResults(SearchContentQuery{})
assert.Nil(t, err)
assert.Equal(t, &SearchPageResults{
Results: []SearchPageResult{},
TotalSize: 1200,
CqlQuery: "testQUERY",
SearchDuration: 100,
Links: Links{
Base: "base",
},
}, s)
}
func Test_api_getSearchEndpoint(t *testing.T) {
api, err := newAPI("https://test.test", "username", "token")
assert.Nil(t, err)
got, err := api.getSearchEndpoint()
assert.Nil(t, err)
assert.Equal(t, "/search", got.Path)
}
func Test_addSearchQueryParams(t *testing.T) {
cql := "type IN (blogpost, page)"
query := SearchContentQuery{
Cql: cql,
Limit: 1,
}
got := addSearchQueryParams(query)
want := url.Values{}
want.Set("cql", cql)
want.Set("limit", "1")
if !reflect.DeepEqual(got, &want) {
t.Errorf("addSearchQueryParams() = %v, want %v", got, &want)
}
}