MCPcopy Create free account
hub / github.com/cli/cli / TestSearcherCommits

Function TestSearcherCommits

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

Source from the content-addressed store, hash-verified

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

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