MCPcopy
hub / github.com/cli/cli / TestSearcherRepositories

Function TestSearcherRepositories

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

Source from the content-addressed store, hash-verified

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