MCPcopy
hub / github.com/cli/cli / TestSearchIssuesAndAdvancedSearch

Function TestSearchIssuesAndAdvancedSearch

pkg/cmd/issue/list/http_test.go:172–216  ·  view source on GitHub ↗

TODO advancedIssueSearchCleanup Remove this test once GHES 3.17 support ends.

(t *testing.T)

Source from the content-addressed store, hash-verified

170// TODO advancedIssueSearchCleanup
171// Remove this test once GHES 3.17 support ends.
172func TestSearchIssuesAndAdvancedSearch(t *testing.T) {
173 tests := []struct {
174 name string
175 detector fd.Detector
176 wantSearchType string
177 }{
178 {
179 name: "advanced issue search not supported",
180 detector: fd.AdvancedIssueSearchUnsupported(),
181 wantSearchType: "ISSUE",
182 },
183 {
184 name: "advanced issue search supported as opt-in",
185 detector: fd.AdvancedIssueSearchSupportedAsOptIn(),
186 wantSearchType: "ISSUE_ADVANCED",
187 },
188 {
189 name: "advanced issue search supported as only backend",
190 detector: fd.AdvancedIssueSearchSupportedAsOnlyBackend(),
191 wantSearchType: "ISSUE",
192 },
193 }
194
195 for _, tt := range tests {
196 t.Run(tt.name, func(t *testing.T) {
197 reg := &httpmock.Registry{}
198 defer reg.Verify(t)
199
200 reg.Register(
201 httpmock.GraphQL(`query IssueSearch\b`),
202 httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) {
203 assert.Equal(t, tt.wantSearchType, vars["type"])
204 // Since no repeated usage of special search qualifiers is possible
205 // with our current implementation, we can assert against the same
206 // query for both search backend (i.e. legacy and advanced issue search).
207 assert.Equal(t, "repo:OWNER/REPO state:open type:issue", vars["query"])
208 }))
209
210 httpClient := &http.Client{Transport: reg}
211 client := api.NewClientFromHTTP(httpClient)
212
213 searchIssues(client, tt.detector, ghrepo.New("OWNER", "REPO"), prShared.FilterOptions{State: "open"}, 30)
214 })
215 }
216}
217
218func TestSearchIssues_rejectsPullRequestQualifiers(t *testing.T) {
219 tests := []struct {

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
GraphQLQueryFunction · 0.92
NewClientFromHTTPFunction · 0.92
NewFunction · 0.92
searchIssuesFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected