(t *testing.T)
| 661 | } |
| 662 | |
| 663 | func TestPrMerge_deleteBranch_apiError(t *testing.T) { |
| 664 | tests := []struct { |
| 665 | name string |
| 666 | apiError ghapi.HTTPError |
| 667 | wantErr string |
| 668 | wantStderr string |
| 669 | }{ |
| 670 | { |
| 671 | name: "branch already deleted (422: Reference does not exist)", |
| 672 | apiError: ghapi.HTTPError{ |
| 673 | Message: "Reference does not exist", |
| 674 | StatusCode: http.StatusUnprocessableEntity, // 422 |
| 675 | }, |
| 676 | wantStderr: heredoc.Doc(` |
| 677 | ✓ Merged pull request OWNER/REPO#10 (Blueberries are a good fruit) |
| 678 | ✓ Deleted local branch blueberries and switched to branch main |
| 679 | ✓ Deleted remote branch blueberries |
| 680 | `), |
| 681 | }, |
| 682 | { |
| 683 | name: "branch already deleted (404: Reference does not exist) (#11187)", |
| 684 | apiError: ghapi.HTTPError{ |
| 685 | Message: "Reference does not exist", |
| 686 | StatusCode: http.StatusNotFound, // 404 |
| 687 | }, |
| 688 | wantStderr: heredoc.Doc(` |
| 689 | ✓ Merged pull request OWNER/REPO#10 (Blueberries are a good fruit) |
| 690 | ✓ Deleted local branch blueberries and switched to branch main |
| 691 | ✓ Deleted remote branch blueberries |
| 692 | `), |
| 693 | }, |
| 694 | { |
| 695 | name: "unknown API error", |
| 696 | apiError: ghapi.HTTPError{ |
| 697 | Message: "blah blah", |
| 698 | StatusCode: http.StatusInternalServerError, // 500 |
| 699 | }, |
| 700 | wantStderr: heredoc.Doc(` |
| 701 | ✓ Merged pull request OWNER/REPO#10 (Blueberries are a good fruit) |
| 702 | ✓ Deleted local branch blueberries and switched to branch main |
| 703 | `), |
| 704 | wantErr: "failed to delete remote branch blueberries: HTTP 500: blah blah (https://api.github.com/repos/OWNER/REPO/git/refs/heads/blueberries)", |
| 705 | }, |
| 706 | } |
| 707 | |
| 708 | for _, tt := range tests { |
| 709 | t.Run(tt.name, func(t *testing.T) { |
| 710 | http := initFakeHTTP() |
| 711 | defer http.Verify(t) |
| 712 | |
| 713 | shared.StubFinderForRunCommandStyleTests(t, |
| 714 | "", |
| 715 | &api.PullRequest{ |
| 716 | ID: "PR_10", |
| 717 | Number: 10, |
| 718 | State: "OPEN", |
| 719 | Title: "Blueberries are a good fruit", |
| 720 | HeadRefName: "blueberries", |
nothing calls this directly
no test coverage detected