MCPcopy
hub / github.com/cli/cli / TestSearcherIssues

Function TestSearcherIssues

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

Source from the content-addressed store, hash-verified

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