MCPcopy
hub / github.com/cli/cli / TestSearcherCommits

Function TestSearcherCommits

pkg/search/searcher_test.go:281–565  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func 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{

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
CommitsMethod · 0.95
QueryMatcherFunction · 0.92
JSONResponseFunction · 0.92
WithHeaderFunction · 0.92
StatusStringResponseFunction · 0.92
initializeFunction · 0.85
NewSearcherFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected