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