|
|
|
@ -27,7 +27,7 @@ func TestSearchService_Repositories(t *testing.T) { |
|
|
|
"per_page": "2", |
|
|
|
}) |
|
|
|
|
|
|
|
fmt.Fprint(w, `{"total_count": 4, "items": [{"id":1},{"id":2}]}`) |
|
|
|
fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`) |
|
|
|
}) |
|
|
|
|
|
|
|
opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
|
|
|
@ -37,8 +37,9 @@ func TestSearchService_Repositories(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
want := &RepositoriesSearchResult{ |
|
|
|
Total: Int(4), |
|
|
|
Repositories: []Repository{{ID: Int(1)}, {ID: Int(2)}}, |
|
|
|
Total: Int(4), |
|
|
|
IncompleteResults: Bool(false), |
|
|
|
Repositories: []Repository{{ID: Int(1)}, {ID: Int(2)}}, |
|
|
|
} |
|
|
|
if !reflect.DeepEqual(result, want) { |
|
|
|
t.Errorf("Search.Repositories returned %+v, want %+v", result, want) |
|
|
|
@ -59,7 +60,7 @@ func TestSearchService_Issues(t *testing.T) { |
|
|
|
"per_page": "2", |
|
|
|
}) |
|
|
|
|
|
|
|
fmt.Fprint(w, `{"total_count": 4, "items": [{"number":1},{"number":2}]}`) |
|
|
|
fmt.Fprint(w, `{"total_count": 4, "incomplete_results": true, "items": [{"number":1},{"number":2}]}`) |
|
|
|
}) |
|
|
|
|
|
|
|
opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
|
|
|
@ -69,8 +70,9 @@ func TestSearchService_Issues(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
want := &IssuesSearchResult{ |
|
|
|
Total: Int(4), |
|
|
|
Issues: []Issue{{Number: Int(1)}, {Number: Int(2)}}, |
|
|
|
Total: Int(4), |
|
|
|
IncompleteResults: Bool(true), |
|
|
|
Issues: []Issue{{Number: Int(1)}, {Number: Int(2)}}, |
|
|
|
} |
|
|
|
if !reflect.DeepEqual(result, want) { |
|
|
|
t.Errorf("Search.Issues returned %+v, want %+v", result, want) |
|
|
|
@ -91,7 +93,7 @@ func TestSearchService_Users(t *testing.T) { |
|
|
|
"per_page": "2", |
|
|
|
}) |
|
|
|
|
|
|
|
fmt.Fprint(w, `{"total_count": 4, "items": [{"id":1},{"id":2}]}`) |
|
|
|
fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`) |
|
|
|
}) |
|
|
|
|
|
|
|
opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
|
|
|
@ -101,8 +103,9 @@ func TestSearchService_Users(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
want := &UsersSearchResult{ |
|
|
|
Total: Int(4), |
|
|
|
Users: []User{{ID: Int(1)}, {ID: Int(2)}}, |
|
|
|
Total: Int(4), |
|
|
|
IncompleteResults: Bool(false), |
|
|
|
Users: []User{{ID: Int(1)}, {ID: Int(2)}}, |
|
|
|
} |
|
|
|
if !reflect.DeepEqual(result, want) { |
|
|
|
t.Errorf("Search.Users returned %+v, want %+v", result, want) |
|
|
|
@ -123,7 +126,7 @@ func TestSearchService_Code(t *testing.T) { |
|
|
|
"per_page": "2", |
|
|
|
}) |
|
|
|
|
|
|
|
fmt.Fprint(w, `{"total_count": 4, "items": [{"name":"1"},{"name":"2"}]}`) |
|
|
|
fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"name":"1"},{"name":"2"}]}`) |
|
|
|
}) |
|
|
|
|
|
|
|
opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
|
|
|
@ -133,8 +136,9 @@ func TestSearchService_Code(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
want := &CodeSearchResult{ |
|
|
|
Total: Int(4), |
|
|
|
CodeResults: []CodeResult{{Name: String("1")}, {Name: String("2")}}, |
|
|
|
Total: Int(4), |
|
|
|
IncompleteResults: Bool(false), |
|
|
|
CodeResults: []CodeResult{{Name: String("1")}, {Name: String("2")}}, |
|
|
|
} |
|
|
|
if !reflect.DeepEqual(result, want) { |
|
|
|
t.Errorf("Search.Code returned %+v, want %+v", result, want) |
|
|
|
@ -151,6 +155,7 @@ func TestSearchService_CodeTextMatch(t *testing.T) { |
|
|
|
textMatchResponse := ` |
|
|
|
{ |
|
|
|
"total_count": 1, |
|
|
|
"incomplete_results": false, |
|
|
|
"items": [ |
|
|
|
{ |
|
|
|
"name":"gopher1", |
|
|
|
@ -192,8 +197,9 @@ func TestSearchService_CodeTextMatch(t *testing.T) { |
|
|
|
} |
|
|
|
|
|
|
|
want := &CodeSearchResult{ |
|
|
|
Total: Int(1), |
|
|
|
CodeResults: []CodeResult{wantedCodeResult}, |
|
|
|
Total: Int(1), |
|
|
|
IncompleteResults: Bool(false), |
|
|
|
CodeResults: []CodeResult{wantedCodeResult}, |
|
|
|
} |
|
|
|
if !reflect.DeepEqual(result, want) { |
|
|
|
t.Errorf("Search.Code returned %+v, want %+v", result, want) |
|
|
|
|