-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquery_test.go
43 lines (37 loc) · 1011 Bytes
/
query_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
package gol_test
import (
"testing"
"github.com/Open-pi/gol"
)
func TestQuery(t *testing.T) {
//url := gol.QueryUrl().Type("edition").Author("OL236174A").Limit(2).Construct()
//tr, err := gol.Query(url)
//if err != nil {
//t.Errorf("got unexpected error %v", err)
//}
//log.Println(tr)
}
func TestQueryURL(t *testing.T) {
tt := []struct {
name string
expected string
output string
}{
{
"query editions by author with limit",
gol.QueryUrl().Type("edition").Author("OL236174A").Limit(2).Construct(),
"https://openlibrary.org/query.json?&type=/type/edition&authors=/authors/OL236174A&limit=2",
}, {
"query editions by author and get title",
gol.QueryUrl().Type("edition").Author("OL236174A").Title("").Construct(),
"https://openlibrary.org/query.json?&type=/type/edition&authors=/authors/OL236174A&title=",
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
if tc.expected != tc.output {
t.Fatalf("got unexpected result")
}
})
}
}