(t *testing.T)
| 217 | } |
| 218 | |
| 219 | func TestPRRevert_APIFailure(t *testing.T) { |
| 220 | http := &httpmock.Registry{} |
| 221 | defer http.Verify(t) |
| 222 | |
| 223 | shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{ |
| 224 | ID: "SOME-ID", |
| 225 | Number: 123, |
| 226 | State: "MERGED", |
| 227 | Title: "The title of the PR", |
| 228 | }, ghrepo.New("OWNER", "REPO")) |
| 229 | |
| 230 | http.Register( |
| 231 | httpmock.GraphQL(`mutation PullRequestRevert\b`), |
| 232 | httpmock.GraphQLMutation(` |
| 233 | { "errors": [{ |
| 234 | "message": "Authorization error" |
| 235 | }]}`, |
| 236 | func(inputs map[string]interface{}) { |
| 237 | assert.Equal(t, inputs["pullRequestId"], "SOME-ID") |
| 238 | }), |
| 239 | ) |
| 240 | |
| 241 | output, err := runCommand(http, true, "123") |
| 242 | // Non-zero exit, stderr shows the API error, stdout empty. |
| 243 | assert.EqualError(t, err, "API call failed: GraphQL: Authorization error") |
| 244 | assert.Equal(t, "X GraphQL: Authorization error\n", output.Stderr()) |
| 245 | assert.Equal(t, "", output.String()) |
| 246 | } |
| 247 | |
| 248 | func TestPRRevert_multipleInvocations(t *testing.T) { |
| 249 | http := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected