MCPcopy
hub / github.com/cli/cli / TestPrClose_deleteBranch_crossRepo

Function TestPrClose_deleteBranch_crossRepo

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

Source from the content-addressed store, hash-verified

176}
177
178func TestPrClose_deleteBranch_crossRepo(t *testing.T) {
179 http := &httpmock.Registry{}
180 defer http.Verify(t)
181
182 baseRepo, pr := stubPR("OWNER/REPO", "hubot/REPO:blueberries")
183 pr.Title = "The title of the PR"
184 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
185
186 http.Register(
187 httpmock.GraphQL(`mutation PullRequestClose\b`),
188 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
189 func(inputs map[string]interface{}) {
190 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
191 }),
192 )
193
194 cs, cmdTeardown := run.Stub()
195 defer cmdTeardown(t)
196
197 cs.Register(`git rev-parse --verify refs/heads/blueberries`, 0, "")
198 cs.Register(`git branch -D blueberries`, 0, "")
199
200 output, err := runCommand(http, true, `96 --delete-branch`)
201 assert.NoError(t, err)
202 assert.Equal(t, "", output.String())
203 assert.Equal(t, heredoc.Doc(`
204 ✓ Closed pull request OWNER/REPO#96 (The title of the PR)
205 ! Skipped deleting the remote branch of a pull request from fork
206 ✓ Deleted branch blueberries
207 `), output.Stderr())
208}
209
210func TestPrClose_deleteBranch_sameBranch(t *testing.T) {
211 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected