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

Function TestSearcherIssues

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

Source from the content-addressed store, hash-verified

852}
853
854func TestSearcherIssues(t *testing.T) {
855 query := Query{
856 Keywords: []string{"keyword"},
857 Kind: "issues",
858 Limit: 30,
859 Order: "desc",
860 Sort: "comments",
861 Qualifiers: Qualifiers{
862 Language: "go",
863 Is: []string{"public", "locked"},
864 },
865 }
866
867 values := url.Values{
868 "page": []string{"1"},
869 "per_page": []string{"30"},
870 "order": []string{"desc"},
871 "sort": []string{"comments"},
872 "q": []string{"keyword is:locked is:public language:go"},
873 }
874
875 tests := []struct {
876 name string
877 host string
878 query Query
879 result IssuesResult
880 wantErr bool
881 errMsg string
882 httpStubs func(*httpmock.Registry)
883 }{
884 {
885 name: "searches issues",
886 query: query,
887 result: IssuesResult{
888 IncompleteResults: false,
889 Items: []Issue{{Number: 1234}},
890 Total: 1,
891 },
892 httpStubs: func(reg *httpmock.Registry) {
893 reg.Register(
894 httpmock.QueryMatcher("GET", "search/issues", values),
895 httpmock.JSONResponse(map[string]any{
896 "incomplete_results": false,
897 "total_count": 1,
898 "items": []any{
899 map[string]any{
900 "number": 1234,
901 },
902 },
903 }),
904 )
905 },
906 },
907 {
908 name: "searches issues for enterprise host",
909 host: "enterprise.com",
910 query: query,
911 result: IssuesResult{

Callers

nothing calls this directly

Calls 11

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