MCPcopy
hub / github.com/cli/cli / TestPrClose_withComment

Function TestPrClose_withComment

pkg/cmd/pr/close/close_test.go:279–310  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestPrClose_withComment(t *testing.T) {
280 http := &httpmock.Registry{}
281 defer http.Verify(t)
282
283 baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
284 pr.Title = "The title of the PR"
285 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
286
287 http.Register(
288 httpmock.GraphQL(`mutation CommentCreate\b`),
289 httpmock.GraphQLMutation(`
290 { "data": { "addComment": { "commentEdge": { "node": {
291 "url": "https://github.com/OWNER/REPO/issues/123#issuecomment-456"
292 } } } } }`,
293 func(inputs map[string]interface{}) {
294 assert.Equal(t, "THE-ID", inputs["subjectId"])
295 assert.Equal(t, "closing comment", inputs["body"])
296 }),
297 )
298 http.Register(
299 httpmock.GraphQL(`mutation PullRequestClose\b`),
300 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
301 func(inputs map[string]interface{}) {
302 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
303 }),
304 )
305
306 output, err := runCommand(http, true, "96 --comment 'closing comment'")
307 assert.NoError(t, err)
308 assert.Equal(t, "", output.String())
309 assert.Equal(t, "✓ Closed pull request OWNER/REPO#96 (The title of the PR)\n", output.Stderr())
310}

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
GraphQLMutationFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
stubPRFunction · 0.70
runCommandFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected