MCPcopy Index your code
hub / github.com/cli/cli / TestPRRevert_APIFailure

Function TestPRRevert_APIFailure

pkg/cmd/pr/revert/revert_test.go:219–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

217}
218
219func 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
248func TestPRRevert_multipleInvocations(t *testing.T) {
249 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 10

VerifyMethod · 0.95
RegisterMethod · 0.95
NewFunction · 0.92
GraphQLFunction · 0.92
GraphQLMutationFunction · 0.92
EqualMethod · 0.80
StderrMethod · 0.80
runCommandFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected