MCPcopy
hub / github.com/cli/cli / TestSearchPullRequestsAndAdvancedSearch

Function TestSearchPullRequestsAndAdvancedSearch

pkg/cmd/pr/list/http_test.go:182–226  ·  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

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected