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)
| 2219 | // multiple IssueNodeID lookups and need stubs to route by issue number |
| 2220 | // rather than by registration order. |
| 2221 | func 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 | } |
no test coverage detected