MCPcopy
hub / github.com/cli/cli / TestPrClose_deleteBranch_notInGitRepo

Function TestPrClose_deleteBranch_notInGitRepo

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

Source from the content-addressed store, hash-verified

243}
244
245func TestPrClose_deleteBranch_notInGitRepo(t *testing.T) {
246 http := &httpmock.Registry{}
247 defer http.Verify(t)
248
249 baseRepo, pr := stubPR("OWNER/REPO:main", "OWNER/REPO:trunk")
250 pr.Title = "The title of the PR"
251 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
252
253 http.Register(
254 httpmock.GraphQL(`mutation PullRequestClose\b`),
255 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
256 func(inputs map[string]interface{}) {
257 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
258 }),
259 )
260 http.Register(
261 httpmock.REST("DELETE", "repos/OWNER/REPO/git/refs/heads/trunk"),
262 httpmock.StringResponse(`{}`))
263
264 cs, cmdTeardown := run.Stub()
265 defer cmdTeardown(t)
266
267 cs.Register(`git rev-parse --verify refs/heads/trunk`, 128, "could not determine current branch: fatal: not a git repository (or any of the parent directories): .git")
268
269 output, err := runCommand(http, true, `96 --delete-branch`)
270 assert.NoError(t, err)
271 assert.Equal(t, "", output.String())
272 assert.Equal(t, heredoc.Doc(`
273 ✓ Closed pull request OWNER/REPO#96 (The title of the PR)
274 ! Skipped deleting the local branch since current directory is not a git repository
275 ✓ Deleted branch trunk
276 `), output.Stderr())
277}
278
279func TestPrClose_withComment(t *testing.T) {
280 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