(t *testing.T)
| 279 | } |
| 280 | |
| 281 | func TestSearcherCommits(t *testing.T) { |
| 282 | query := Query{ |
| 283 | Keywords: []string{"keyword"}, |
| 284 | Kind: "commits", |
| 285 | Limit: 30, |
| 286 | Order: "desc", |
| 287 | Sort: "committer-date", |
| 288 | Qualifiers: Qualifiers{ |
| 289 | Author: "foobar", |
| 290 | CommitterDate: ">2021-02-28", |
| 291 | }, |
| 292 | } |
| 293 | |
| 294 | values := url.Values{ |
| 295 | "page": []string{"1"}, |
| 296 | "per_page": []string{"30"}, |
| 297 | "order": []string{"desc"}, |
| 298 | "sort": []string{"committer-date"}, |
| 299 | "q": []string{"keyword author:foobar committer-date:>2021-02-28"}, |
| 300 | } |
| 301 | |
| 302 | tests := []struct { |
| 303 | name string |
| 304 | host string |
| 305 | query Query |
| 306 | result CommitsResult |
| 307 | wantErr bool |
| 308 | errMsg string |
| 309 | httpStubs func(*httpmock.Registry) |
| 310 | }{ |
| 311 | { |
| 312 | name: "searches commits", |
| 313 | query: query, |
| 314 | result: CommitsResult{ |
| 315 | IncompleteResults: false, |
| 316 | Items: []Commit{{Sha: "abc"}}, |
| 317 | Total: 1, |
| 318 | }, |
| 319 | httpStubs: func(reg *httpmock.Registry) { |
| 320 | reg.Register( |
| 321 | httpmock.QueryMatcher("GET", "search/commits", values), |
| 322 | httpmock.JSONResponse(map[string]interface{}{ |
| 323 | "incomplete_results": false, |
| 324 | "total_count": 1, |
| 325 | "items": []interface{}{ |
| 326 | map[string]interface{}{ |
| 327 | "sha": "abc", |
| 328 | }, |
| 329 | }, |
| 330 | }), |
| 331 | ) |
| 332 | }, |
| 333 | }, |
| 334 | { |
| 335 | name: "searches commits for enterprise host", |
| 336 | host: "enterprise.com", |
| 337 | query: query, |
| 338 | result: CommitsResult{ |
nothing calls this directly
no test coverage detected