MCPcopy
hub / github.com/cli/cli / TestPrClose_deleteBranch_sameBranch

Function TestPrClose_deleteBranch_sameBranch

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

Source from the content-addressed store, hash-verified

208}
209
210func TestPrClose_deleteBranch_sameBranch(t *testing.T) {
211 http := &httpmock.Registry{}
212 defer http.Verify(t)
213
214 baseRepo, pr := stubPR("OWNER/REPO:main", "OWNER/REPO:trunk")
215 pr.Title = "The title of the PR"
216 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
217
218 http.Register(
219 httpmock.GraphQL(`mutation PullRequestClose\b`),
220 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
221 func(inputs map[string]interface{}) {
222 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
223 }),
224 )
225 http.Register(
226 httpmock.REST("DELETE", "repos/OWNER/REPO/git/refs/heads/trunk"),
227 httpmock.StringResponse(`{}`))
228
229 cs, cmdTeardown := run.Stub()
230 defer cmdTeardown(t)
231
232 cs.Register(`git checkout main`, 0, "")
233 cs.Register(`git rev-parse --verify refs/heads/trunk`, 0, "")
234 cs.Register(`git branch -D trunk`, 0, "")
235
236 output, err := runCommand(http, true, `96 --delete-branch`)
237 assert.NoError(t, err)
238 assert.Equal(t, "", output.String())
239 assert.Equal(t, heredoc.Doc(`
240 ✓ Closed pull request OWNER/REPO#96 (The title of the PR)
241 ✓ Deleted branch trunk and switched to branch main
242 `), output.Stderr())
243}
244
245func TestPrClose_deleteBranch_notInGitRepo(t *testing.T) {
246 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 13

VerifyMethod · 0.95
RegisterMethod · 0.95
GraphQLFunction · 0.92
GraphQLMutationFunction · 0.92
RESTFunction · 0.92
StringResponseFunction · 0.92
StubFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
stubPRFunction · 0.70
runCommandFunction · 0.70

Tested by

no test coverage detected