1
1
package openbd
2
2
3
3
import (
4
+ "context"
4
5
"net/http"
5
6
"net/url"
6
7
"testing"
7
8
)
8
9
9
- // func TestLookupBooksRaw(t *testing.T) {
10
- // testCases := []struct {
11
- // ids []string
12
- // }{
13
- // {ids: nil},
14
- // {ids: []string{}},
15
- // {ids: []string{"foo"}},
16
- // {ids: []string{"9784535585744"}},
17
- // {ids: []string{"9784535585744", "9784797369915"}},
18
- // {ids: []string{"9784535585744", "foo"}},
19
- // {ids: []string{"9784535585744&isbn=9784797369915"}},
20
- // }
21
- //
22
- // for _, tc := range testCases {
23
- // b, err := DefaultClient().LookupBooksRaw(tc.ids)
24
- // if err != nil {
25
- // t.Errorf("Client.LookupBooksRaw() is \"%v\", want nil", err)
26
- // fmt.Printf("error info: %+v\n", err)
27
- // continue
28
- // }
29
- // fmt.Printf("response: %+v\n", string(b))
30
- // }
31
- // }
32
- //
33
- // func TestLookupBooks(t *testing.T) {
34
- // testCases := []struct {
35
- // ids []string
36
- // valid []bool
37
- // }{
38
- // {ids: nil, valid: []bool{false}},
39
- // {ids: []string{}, valid: []bool{false}},
40
- // {ids: []string{"foo"}, valid: []bool{false}},
41
- // {ids: []string{"9784535585744"}, valid: []bool{true}},
42
- // {ids: []string{"9784535585744", "9784797369915"}, valid: []bool{true, true}},
43
- // {ids: []string{"9784535585744", "foo"}, valid: []bool{true, false}},
44
- // {ids: []string{"9784535585744&isbn=9784797369915"}, valid: []bool{false}},
45
- // }
46
- //
47
- // for _, tc := range testCases {
48
- // bks, err := DefaultClient().LookupBooks(tc.ids)
49
- // if err != nil {
50
- // t.Errorf("Client.LookupBooks() is \"%v\", want nil", err)
51
- // fmt.Printf("error info: %+v\n", err)
52
- // continue
53
- // }
54
- // if len(bks) != len(tc.valid) {
55
- // t.Errorf("Count of Client.LookupBooks() is %v, want %v", len(bks), len(tc.valid))
56
- // continue
57
- // }
58
- // for i, bk := range bks {
59
- // if bk.Valid() != tc.valid[i] {
60
- // t.Errorf("Book[%d] is %v, want %v", i, bk.Valid(), tc.valid[i])
61
- // continue
62
- // }
63
- // if bk.Valid() {
64
- // id := bk.Id()
65
- // if id != tc.ids[i] {
66
- // t.Errorf("Book[%d] is %v, want %v", i, id, tc.ids[i])
67
- // }
68
- // }
69
- // }
70
- // }
71
- // }
72
-
73
10
func TestMakeLookupCommand (t * testing.T ) {
74
11
testCases := []struct {
75
12
v url.Values
@@ -87,7 +24,7 @@ func TestMakeLookupCommand(t *testing.T) {
87
24
if u .String () != tc .str {
88
25
t .Errorf ("Client.MakeLookupCommand() is \" %v\" , want \" %v\" " , u .String (), tc .str )
89
26
}
90
- u = (* Server )(nil ).CreateClient (nil , & http.Client {}).MakeLookupCommand (tc .v )
27
+ u = (* Server )(nil ).CreateClient (WithContext ( context . Background ()), WithHttpCilent ( & http.Client {}) ).MakeLookupCommand (tc .v )
91
28
if u .String () != tc .str {
92
29
t .Errorf ("Client.MakeLookupCommand() is \" %v\" , want \" %v\" " , u .String (), tc .str )
93
30
}
0 commit comments