(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestSearchService_Topics(t *testing.T) { |
| 153 | t.Parallel() |
| 154 | client, mux, _ := setup(t) |
| 155 | |
| 156 | mux.HandleFunc("/search/topics", func(w http.ResponseWriter, r *http.Request) { |
| 157 | testMethod(t, r, "GET") |
| 158 | testFormValues(t, r, values{ |
| 159 | "q": "blah", |
| 160 | "page": "2", |
| 161 | "per_page": "2", |
| 162 | }) |
| 163 | |
| 164 | fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"name":"blah"},{"name":"blahblah"}]}`) |
| 165 | }) |
| 166 | |
| 167 | opts := &SearchOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}} |
| 168 | ctx := t.Context() |
| 169 | result, _, err := client.Search.Topics(ctx, "blah", opts) |
| 170 | if err != nil { |
| 171 | t.Errorf("Search.Topics returned error: %v", err) |
| 172 | } |
| 173 | |
| 174 | want := &TopicsSearchResult{ |
| 175 | Total: Ptr(4), |
| 176 | IncompleteResults: Ptr(false), |
| 177 | Topics: []*TopicResult{{Name: Ptr("blah")}, {Name: Ptr("blahblah")}}, |
| 178 | } |
| 179 | if !cmp.Equal(result, want) { |
| 180 | t.Errorf("Search.Topics returned %+v, want %+v", result, want) |
| 181 | } |
| 182 | const methodName = "Topics" |
| 183 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 184 | got, resp, err := client.Search.Topics(ctx, "blah", opts) |
| 185 | if got != nil { |
| 186 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 187 | } |
| 188 | return resp, err |
| 189 | }) |
| 190 | } |
| 191 | |
| 192 | func TestSearchService_Topics_coverage(t *testing.T) { |
| 193 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…