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

Function issueNodeIDByNumberMatcher

pkg/cmd/issue/edit/edit_test.go:2286–2307  ·  view source on GitHub ↗

issueNodeIDByNumberMatcher matches an IssueNodeID GraphQL query whose number variable equals the given value. Used by tests that issue multiple IssueNodeID lookups and need stubs to route by issue number rather than by registration order.

(number int)

Source from the content-addressed store, hash-verified

2284// multiple IssueNodeID lookups and need stubs to route by issue number
2285// rather than by registration order.
2286func issueNodeIDByNumberMatcher(number int) httpmock.Matcher {
2287 queryMatcher := httpmock.GraphQL(`query IssueNodeID\b`)
2288 return func(req *http.Request) bool {
2289 if !queryMatcher(req) {
2290 return false
2291 }
2292 body, err := io.ReadAll(req.Body)
2293 if err != nil {
2294 return false
2295 }
2296 req.Body = io.NopCloser(bytes.NewReader(body))
2297 var b struct {
2298 Variables struct {
2299 Number int `json:"number"`
2300 } `json:"variables"`
2301 }
2302 if err := json.Unmarshal(body, &b); err != nil {
2303 return false
2304 }
2305 return b.Variables.Number == number
2306 }
2307}

Callers 1

Test_editRunFunction · 0.70

Calls 1

GraphQLFunction · 0.92

Tested by

no test coverage detected