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

Function TestPRRevert_withDraft

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

Source from the content-addressed store, hash-verified

181}
182
183func 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
219func TestPRRevert_APIFailure(t *testing.T) {
220 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