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

Function TestPrClose

pkg/cmd/pr/close/close_test.go:107–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestPrClose(t *testing.T) {
108 http := &httpmock.Registry{}
109 defer http.Verify(t)
110
111 baseRepo, pr := stubPR("OWNER/REPO", "OWNER/REPO:feature")
112 pr.Title = "The title of the PR"
113 shared.StubFinderForRunCommandStyleTests(t, "96", pr, baseRepo)
114
115 http.Register(
116 httpmock.GraphQL(`mutation PullRequestClose\b`),
117 httpmock.GraphQLMutation(`{"id": "THE-ID"}`,
118 func(inputs map[string]interface{}) {
119 assert.Equal(t, inputs["pullRequestId"], "THE-ID")
120 }),
121 )
122
123 output, err := runCommand(http, true, "96")
124 assert.NoError(t, err)
125 assert.Equal(t, "", output.String())
126 assert.Equal(t, "✓ Closed pull request OWNER/REPO#96 (The title of the PR)\n", output.Stderr())
127}
128
129func TestPrClose_alreadyClosed(t *testing.T) {
130 http := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected