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

Function TestPRRevert_acceptedIdentifierFormats

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

Source from the content-addressed store, hash-verified

67}
68
69func TestPRRevert_acceptedIdentifierFormats(t *testing.T) {
70 tests := []struct {
71 name string
72 args string
73 }{
74 {
75 name: "Revert by pull request number",
76 args: "123",
77 },
78 {
79 name: "Revert by pull request identifier",
80 args: "owner/repo#123",
81 },
82 {
83 name: "Revert by pull request URL",
84 args: "https://github.com/owner/repo/pull/123",
85 },
86 }
87
88 for _, tt := range tests {
89 t.Run(tt.name, func(t *testing.T) {
90
91 http := &httpmock.Registry{}
92 defer http.Verify(t)
93
94 shared.StubFinderForRunCommandStyleTests(t, tt.args, &api.PullRequest{
95 ID: "SOME-ID",
96 Number: 123,
97 State: "MERGED",
98 Title: "The title of the PR",
99 }, ghrepo.New("OWNER", "REPO"))
100
101 http.Register(
102 httpmock.GraphQL(`mutation PullRequestRevert\b`),
103 httpmock.GraphQLMutation(`
104 { "data": { "revertPullRequest": { "pullRequest": {
105 "ID": "SOME-ID"
106 }, "revertPullRequest": {
107 "ID": "NEW-ID",
108 "Number": 456,
109 "URL": "https://github.com/OWNER/REPO/pull/456"
110 } } } }
111 `,
112 func(inputs map[string]interface{}) {
113 assert.Equal(t, inputs["pullRequestId"], "SOME-ID")
114 }),
115 )
116
117 output, err := runCommand(http, true, tt.args)
118 // Revert PR is created and only its URL is printed.
119 assert.NoError(t, err)
120 assert.Equal(t, "https://github.com/OWNER/REPO/pull/456\n", output.String())
121 assert.Equal(t, "", output.Stderr())
122 })
123 }
124}
125
126func TestPRRevert_notRevertable(t *testing.T) {

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected