(t *testing.T)
| 181 | } |
| 182 | |
| 183 | func TestPRRevert_withDraft(t *testing.T) { |
| 184 | http := &httpmock.Registry{} |
| 185 | defer http.Verify(t) |
| 186 | |
| 187 | shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{ |
| 188 | ID: "SOME-ID", |
| 189 | Number: 123, |
| 190 | State: "MERGED", |
| 191 | Title: "The title of the PR", |
| 192 | }, ghrepo.New("OWNER", "REPO")) |
| 193 | |
| 194 | http.Register( |
| 195 | httpmock.GraphQL(`mutation PullRequestRevert\b`), |
| 196 | httpmock.GraphQLMutation(` |
| 197 | { "data": { "revertPullRequest": { "pullRequest": { |
| 198 | "ID": "SOME-ID" |
| 199 | }, "revertPullRequest": { |
| 200 | "ID": "NEW-ID", |
| 201 | "Number": 456, |
| 202 | "URL": "https://github.com/OWNER/REPO/pull/456" |
| 203 | } } } } |
| 204 | `, |
| 205 | func(inputs map[string]interface{}) { |
| 206 | assert.Equal(t, inputs["pullRequestId"], "SOME-ID") |
| 207 | assert.Equal(t, inputs["draft"], true) |
| 208 | }), |
| 209 | ) |
| 210 | |
| 211 | output, err := runCommand(http, true, "123 --draft") |
| 212 | // Revert PR created as a draft. |
| 213 | assert.NoError(t, err) |
| 214 | // Only URL printed. |
| 215 | assert.Equal(t, "https://github.com/OWNER/REPO/pull/456\n", output.String()) |
| 216 | assert.Equal(t, "", output.Stderr()) |
| 217 | } |
| 218 | |
| 219 | func TestPRRevert_APIFailure(t *testing.T) { |
| 220 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected