MCPcopy
hub / github.com/cli/cli / TestPrClose_deleteBranch_sameRepo

Function TestPrClose_deleteBranch_sameRepo

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

Source from the content-addressed store, hash-verified

142}
143
144func TestPrClose_deleteBranch_sameRepo(t *testing.T) {
145 http := &httpmock.Registry{}
146 defer http.Verify(t)
147
148 baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:blueberries")
149 pr.Title = "The title of the PR"
150 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
151
152 http.Register(
153 httpmock.GraphQL(`mutation PullRequestClose\b`),
154 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
155 func(inputs map[string]interface{}) {
156 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
157 }),
158 )
159 http.Register(
160 httpmock.REST("DELETE", "repos/OWNER/REPO/git/refs/heads/blueberries"),
161 httpmock.StringResponse(`{}`))
162
163 cs, cmdTeardown := run.Stub()
164 defer cmdTeardown(t)
165
166 cs.Register(`git rev-parse --verify refs/heads/blueberries`, 0, "")
167 cs.Register(`git branch -D blueberries`, 0, "")
168
169 output, err := runCommand(http, true, `96 --delete-branch`)
170 assert.NoError(t, err)
171 assert.Equal(t, "", output.String())
172 assert.Equal(t, heredoc.Doc(`
173 ✓ Closed pull request OWNER/REPO#96 (The title of the PR)
174 ✓ Deleted branch blueberries
175 `), output.Stderr())
176}
177
178func TestPrClose_deleteBranch_crossRepo(t *testing.T) {
179 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