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

Function TestPRRevert_withTitleAndBody

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

Source from the content-addressed store, hash-verified

144}
145
146func TestPRRevert_withTitleAndBody(t *testing.T) {
147 http := &httpmock.Registry{}
148 defer http.Verify(t)
149
150 shared.StubFinderForRunCommandStyleTests(t, "123", &api.PullRequest{
151 ID: "SOME-ID",
152 Number: 123,
153 State: "MERGED",
154 Title: "The title of the PR",
155 }, ghrepo.New("OWNER", "REPO"))
156
157 http.Register(
158 httpmock.GraphQL(`mutation PullRequestRevert\b`),
159 httpmock.GraphQLMutation(`
160 { "data": { "revertPullRequest": { "pullRequest": {
161 "ID": "SOME-ID"
162 }, "revertPullRequest": {
163 "ID": "NEW-ID",
164 "Number": 456,
165 "URL": "https://github.com/OWNER/REPO/pull/456"
166 } } } }
167 `,
168 func(inputs map[string]interface{}) {
169 assert.Equal(t, inputs["pullRequestId"], "SOME-ID")
170 assert.Equal(t, inputs["title"], "Revert PR title")
171 assert.Equal(t, inputs["body"], "Revert PR body")
172 }),
173 )
174
175 output, err := runCommand(http, true, "123 --title 'Revert PR title' --body 'Revert PR body'")
176 // Revert PR created.
177 assert.NoError(t, err)
178 // Only URL printed.
179 assert.Equal(t, "https://github.com/OWNER/REPO/pull/456\n", output.String())
180 assert.Equal(t, "", output.Stderr())
181}
182
183func TestPRRevert_withDraft(t *testing.T) {
184 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