diff --git a/github/search.go b/github/search.go index 0c7ffcb..916a2dc 100644 --- a/github/search.go +++ b/github/search.go @@ -40,8 +40,9 @@ type SearchOptions struct { // RepositoriesSearchResult represents the result of a repositories search. type RepositoriesSearchResult struct { - Total *int `json:"total_count,omitempty"` - Repositories []Repository `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Repositories []Repository `json:"items,omitempty"` } // Repositories searches repositories via various criteria. @@ -55,8 +56,9 @@ func (s *SearchService) Repositories(query string, opt *SearchOptions) (*Reposit // IssuesSearchResult represents the result of an issues search. type IssuesSearchResult struct { - Total *int `json:"total_count,omitempty"` - Issues []Issue `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Issues []Issue `json:"items,omitempty"` } // Issues searches issues via various criteria. @@ -70,8 +72,9 @@ func (s *SearchService) Issues(query string, opt *SearchOptions) (*IssuesSearchR // UsersSearchResult represents the result of an issues search. type UsersSearchResult struct { - Total *int `json:"total_count,omitempty"` - Users []User `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + Users []User `json:"items,omitempty"` } // Users searches users via various criteria. @@ -104,8 +107,9 @@ func (tm TextMatch) String() string { // CodeSearchResult represents the result of an code search. type CodeSearchResult struct { - Total *int `json:"total_count,omitempty"` - CodeResults []CodeResult `json:"items,omitempty"` + Total *int `json:"total_count,omitempty"` + IncompleteResults *bool `json:"incomplete_results,omitempty"` + CodeResults []CodeResult `json:"items,omitempty"` } // CodeResult represents a single search result. diff --git a/github/search_test.go b/github/search_test.go index b36043b..4626de0 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -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)