(t *testing.T)
| 208 | } |
| 209 | |
| 210 | func 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 | |
| 245 | func TestPrClose_deleteBranch_notInGitRepo(t *testing.T) { |
| 246 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected