@@ -60,25 +60,37 @@ func Test_SearchRepositories(t *testing.T) {
60
60
{
61
61
name : "successful repository search" ,
62
62
mockedClient : mock .NewMockedHTTPClient (
63
- mock .WithRequestMatch (
63
+ mock .WithRequestMatchHandler (
64
64
mock .GetSearchRepositories ,
65
- mockSearchResult ,
65
+ expectQueryParams (t , map [string ]string {
66
+ "q" : "golang test" ,
67
+ "page" : "2" ,
68
+ "per_page" : "10" ,
69
+ }).andThen (
70
+ mockResponse (t , http .StatusOK , mockSearchResult ),
71
+ ),
66
72
),
67
73
),
68
74
requestArgs : map [string ]interface {}{
69
75
"query" : "golang test" ,
70
- "page" : float64 (1 ),
71
- "per_page" : float64 (30 ),
76
+ "page" : float64 (2 ),
77
+ "per_page" : float64 (10 ),
72
78
},
73
79
expectError : false ,
74
80
expectedResult : mockSearchResult ,
75
81
},
76
82
{
77
83
name : "repository search with default pagination" ,
78
84
mockedClient : mock .NewMockedHTTPClient (
79
- mock .WithRequestMatch (
85
+ mock .WithRequestMatchHandler (
80
86
mock .GetSearchRepositories ,
81
- mockSearchResult ,
87
+ expectQueryParams (t , map [string ]string {
88
+ "q" : "golang test" ,
89
+ "page" : "1" ,
90
+ "per_page" : "30" ,
91
+ }).andThen (
92
+ mockResponse (t , http .StatusOK , mockSearchResult ),
93
+ ),
82
94
),
83
95
),
84
96
requestArgs : map [string ]interface {}{
@@ -195,9 +207,17 @@ func Test_SearchCode(t *testing.T) {
195
207
{
196
208
name : "successful code search with all parameters" ,
197
209
mockedClient : mock .NewMockedHTTPClient (
198
- mock .WithRequestMatch (
210
+ mock .WithRequestMatchHandler (
199
211
mock .GetSearchCode ,
200
- mockSearchResult ,
212
+ expectQueryParams (t , map [string ]string {
213
+ "q" : "fmt.Println language:go" ,
214
+ "sort" : "indexed" ,
215
+ "order" : "desc" ,
216
+ "page" : "1" ,
217
+ "per_page" : "30" ,
218
+ }).andThen (
219
+ mockResponse (t , http .StatusOK , mockSearchResult ),
220
+ ),
201
221
),
202
222
),
203
223
requestArgs : map [string ]interface {}{
@@ -213,9 +233,15 @@ func Test_SearchCode(t *testing.T) {
213
233
{
214
234
name : "code search with minimal parameters" ,
215
235
mockedClient : mock .NewMockedHTTPClient (
216
- mock .WithRequestMatch (
236
+ mock .WithRequestMatchHandler (
217
237
mock .GetSearchCode ,
218
- mockSearchResult ,
238
+ expectQueryParams (t , map [string ]string {
239
+ "q" : "fmt.Println language:go" ,
240
+ "page" : "1" ,
241
+ "per_page" : "30" ,
242
+ }).andThen (
243
+ mockResponse (t , http .StatusOK , mockSearchResult ),
244
+ ),
219
245
),
220
246
),
221
247
requestArgs : map [string ]interface {}{
@@ -336,9 +362,17 @@ func Test_SearchUsers(t *testing.T) {
336
362
{
337
363
name : "successful users search with all parameters" ,
338
364
mockedClient : mock .NewMockedHTTPClient (
339
- mock .WithRequestMatch (
365
+ mock .WithRequestMatchHandler (
340
366
mock .GetSearchUsers ,
341
- mockSearchResult ,
367
+ expectQueryParams (t , map [string ]string {
368
+ "q" : "location:finland language:go" ,
369
+ "sort" : "followers" ,
370
+ "order" : "desc" ,
371
+ "page" : "1" ,
372
+ "per_page" : "30" ,
373
+ }).andThen (
374
+ mockResponse (t , http .StatusOK , mockSearchResult ),
375
+ ),
342
376
),
343
377
),
344
378
requestArgs : map [string ]interface {}{
@@ -354,9 +388,15 @@ func Test_SearchUsers(t *testing.T) {
354
388
{
355
389
name : "users search with minimal parameters" ,
356
390
mockedClient : mock .NewMockedHTTPClient (
357
- mock .WithRequestMatch (
391
+ mock .WithRequestMatchHandler (
358
392
mock .GetSearchUsers ,
359
- mockSearchResult ,
393
+ expectQueryParams (t , map [string ]string {
394
+ "q" : "location:finland language:go" ,
395
+ "page" : "1" ,
396
+ "per_page" : "30" ,
397
+ }).andThen (
398
+ mockResponse (t , http .StatusOK , mockSearchResult ),
399
+ ),
360
400
),
361
401
),
362
402
requestArgs : map [string ]interface {}{
0 commit comments