(t *testing.T)
| 313 | } |
| 314 | |
| 315 | func TestPrMerge(t *testing.T) { |
| 316 | http := initFakeHTTP() |
| 317 | defer http.Verify(t) |
| 318 | |
| 319 | shared.StubFinderForRunCommandStyleTests(t, |
| 320 | "1", |
| 321 | &api.PullRequest{ |
| 322 | ID: "THE-ID", |
| 323 | Number: 1, |
| 324 | State: "OPEN", |
| 325 | Title: "The title of the PR", |
| 326 | MergeStateStatus: "CLEAN", |
| 327 | }, |
| 328 | baseRepo("OWNER", "REPO", "main"), |
| 329 | ) |
| 330 | |
| 331 | http.Register( |
| 332 | httpmock.GraphQL(`mutation PullRequestMerge\b`), |
| 333 | httpmock.GraphQLMutation(`{}`, func(input map[string]any) { |
| 334 | assert.Equal(t, "THE-ID", input["pullRequestId"].(string)) |
| 335 | assert.Equal(t, "MERGE", input["mergeMethod"].(string)) |
| 336 | assert.NotContains(t, input, "commitHeadline") |
| 337 | }), |
| 338 | ) |
| 339 | |
| 340 | cs, cmdTeardown := run.Stub() |
| 341 | defer cmdTeardown(t) |
| 342 | cs.Register(`git rev-parse --verify refs/heads/`, 0, "") |
| 343 | |
| 344 | output, err := runCommand(http, nil, "main", true, "pr merge 1 --merge") |
| 345 | if err != nil { |
| 346 | t.Fatalf("error running command `pr merge`: %v", err) |
| 347 | } |
| 348 | |
| 349 | r := regexp.MustCompile(`Merged pull request OWNER/REPO#1 \(The title of the PR\)`) |
| 350 | |
| 351 | if !r.MatchString(output.Stderr()) { |
| 352 | t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr()) |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | func TestPrMerge_blocked(t *testing.T) { |
| 357 | http := initFakeHTTP() |
nothing calls this directly
no test coverage detected