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

Function issueNodeIDByNumberMatcher

pkg/cmd/issue/create/create_test.go:2221–2242  ·  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

2219// multiple IssueNodeID lookups and need stubs to route by issue number
2220// rather than by registration order.
2221func issueNodeIDByNumberMatcher(number int) httpmock.Matcher {
2222 queryMatcher := httpmock.GraphQL(`query IssueNodeID\b`)
2223 return func(req *http.Request) bool {
2224 if !queryMatcher(req) {
2225 return false
2226 }
2227 body, err := io.ReadAll(req.Body)
2228 if err != nil {
2229 return false
2230 }
2231 req.Body = io.NopCloser(bytes.NewReader(body))
2232 var b struct {
2233 Variables struct {
2234 Number int `json:"number"`
2235 } `json:"variables"`
2236 }
2237 if err := json.Unmarshal(body, &b); err != nil {
2238 return false
2239 }
2240 return b.Variables.Number == number
2241 }
2242}

Callers 1

Test_createRunFunction · 0.70

Calls 1

GraphQLFunction · 0.92

Tested by

no test coverage detected