(t *testing.T)
| 243 | } |
| 244 | |
| 245 | func 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 | |
| 279 | func TestPrClose_withComment(t *testing.T) { |
| 280 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected