@@ -60,25 +60,37 @@ func Test_SearchRepositories(t *testing.T) {
6060{
6161name :"successful repository search" ,
6262mockedClient :mock .NewMockedHTTPClient (
63- mock .WithRequestMatch (
63+ mock .WithRequestMatchHandler (
6464mock .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+ ),
6672),
6773),
6874requestArgs :map [string ]interface {}{
6975"query" :"golang test" ,
70- "page" :float64 (1 ),
71- "per_page" :float64 (30 ),
76+ "page" :float64 (2 ),
77+ "per_page" :float64 (10 ),
7278},
7379expectError :false ,
7480expectedResult :mockSearchResult ,
7581},
7682{
7783name :"repository search with default pagination" ,
7884mockedClient :mock .NewMockedHTTPClient (
79- mock .WithRequestMatch (
85+ mock .WithRequestMatchHandler (
8086mock .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+ ),
8294),
8395),
8496requestArgs :map [string ]interface {}{
@@ -195,9 +207,17 @@ func Test_SearchCode(t *testing.T) {
195207{
196208name :"successful code search with all parameters" ,
197209mockedClient :mock .NewMockedHTTPClient (
198- mock .WithRequestMatch (
210+ mock .WithRequestMatchHandler (
199211mock .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+ ),
201221),
202222),
203223requestArgs :map [string ]interface {}{
@@ -213,9 +233,15 @@ func Test_SearchCode(t *testing.T) {
213233{
214234name :"code search with minimal parameters" ,
215235mockedClient :mock .NewMockedHTTPClient (
216- mock .WithRequestMatch (
236+ mock .WithRequestMatchHandler (
217237mock .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+ ),
219245),
220246),
221247requestArgs :map [string ]interface {}{
@@ -336,9 +362,17 @@ func Test_SearchUsers(t *testing.T) {
336362{
337363name :"successful users search with all parameters" ,
338364mockedClient :mock .NewMockedHTTPClient (
339- mock .WithRequestMatch (
365+ mock .WithRequestMatchHandler (
340366mock .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+ ),
342376),
343377),
344378requestArgs :map [string ]interface {}{
@@ -354,9 +388,15 @@ func Test_SearchUsers(t *testing.T) {
354388{
355389name :"users search with minimal parameters" ,
356390mockedClient :mock .NewMockedHTTPClient (
357- mock .WithRequestMatch (
391+ mock .WithRequestMatchHandler (
358392mock .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+ ),
360400),
361401),
362402requestArgs :map [string ]interface {}{