(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestPRRevert_acceptedIdentifierFormats(t *testing.T) { |
| 70 | tests := []struct { |
| 71 | name string |
| 72 | args string |
| 73 | }{ |
| 74 | { |
| 75 | name: "Revert by pull request number", |
| 76 | args: "123", |
| 77 | }, |
| 78 | { |
| 79 | name: "Revert by pull request identifier", |
| 80 | args: "owner/repo#123", |
| 81 | }, |
| 82 | { |
| 83 | name: "Revert by pull request URL", |
| 84 | args: "https://github.com/owner/repo/pull/123", |
| 85 | }, |
| 86 | } |
| 87 | |
| 88 | for _, tt := range tests { |
| 89 | t.Run(tt.name, func(t *testing.T) { |
| 90 | |
| 91 | http := &httpmock.Registry{} |
| 92 | defer http.Verify(t) |
| 93 | |
| 94 | shared.StubFinderForRunCommandStyleTests(t, tt.args, &api.PullRequest{ |
| 95 | ID: "SOME-ID", |
| 96 | Number: 123, |
| 97 | State: "MERGED", |
| 98 | Title: "The title of the PR", |
| 99 | }, ghrepo.New("OWNER", "REPO")) |
| 100 | |
| 101 | http.Register( |
| 102 | httpmock.GraphQL(`mutation PullRequestRevert\b`), |
| 103 | httpmock.GraphQLMutation(` |
| 104 | { "data": { "revertPullRequest": { "pullRequest": { |
| 105 | "ID": "SOME-ID" |
| 106 | }, "revertPullRequest": { |
| 107 | "ID": "NEW-ID", |
| 108 | "Number": 456, |
| 109 | "URL": "https://github.com/OWNER/REPO/pull/456" |
| 110 | } } } } |
| 111 | `, |
| 112 | func(inputs map[string]interface{}) { |
| 113 | assert.Equal(t, inputs["pullRequestId"], "SOME-ID") |
| 114 | }), |
| 115 | ) |
| 116 | |
| 117 | output, err := runCommand(http, true, tt.args) |
| 118 | // Revert PR is created and only its URL is printed. |
| 119 | assert.NoError(t, err) |
| 120 | assert.Equal(t, "https://github.com/OWNER/REPO/pull/456\n", output.String()) |
| 121 | assert.Equal(t, "", output.Stderr()) |
| 122 | }) |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func TestPRRevert_notRevertable(t *testing.T) { |
nothing calls this directly
no test coverage detected