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

Function TestSearcherRepositories

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

Source from the content-addressed store, hash-verified

566}
567
568func TestSearcherRepositories(t *testing.T) {
569 query := Query{
570 Keywords: []string{"keyword"},
571 Kind: "repositories",
572 Limit: 30,
573 Order: "desc",
574 Sort: "stars",
575 Qualifiers: Qualifiers{
576 Stars: ">=5",
577 Topic: []string{"topic"},
578 },
579 }
580
581 values := url.Values{
582 "page": []string{"1"},
583 "per_page": []string{"30"},
584 "order": []string{"desc"},
585 "sort": []string{"stars"},
586 "q": []string{"keyword stars:>=5 topic:topic"},
587 }
588
589 tests := []struct {
590 name string
591 host string
592 query Query
593 result RepositoriesResult
594 wantErr bool
595 errMsg string
596 httpStubs func(*httpmock.Registry)
597 }{
598 {
599 name: "searches repositories",
600 query: query,
601 result: RepositoriesResult{
602 IncompleteResults: false,
603 Items: []Repository{{Name: "test"}},
604 Total: 1,
605 },
606 httpStubs: func(reg *httpmock.Registry) {
607 reg.Register(
608 httpmock.QueryMatcher("GET", "search/repositories", values),
609 httpmock.JSONResponse(map[string]any{
610 "incomplete_results": false,
611 "total_count": 1,
612 "items": []any{
613 map[string]any{
614 "name": "test",
615 },
616 },
617 }),
618 )
619 },
620 },
621 {
622 name: "searches repositories for enterprise host",
623 host: "enterprise.com",
624 query: query,
625 result: RepositoriesResult{

Callers

nothing calls this directly

Calls 11

RegisterMethod · 0.95
VerifyMethod · 0.95
RepositoriesMethod · 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