MCPcopy
hub / github.com/cli/cli / TestRerun

Function TestRerun

pkg/cmd/run/rerun/rerun_test.go:166–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

164}
165
166func TestRerun(t *testing.T) {
167 tests := []struct {
168 name string
169 httpStubs func(*httpmock.Registry)
170 promptStubs func(*prompter.MockPrompter)
171 opts *RerunOptions
172 tty bool
173 wantErr bool
174 errOut string
175 wantOut string
176 wantDebug bool
177 }{
178 {
179 name: "arg",
180 tty: true,
181 opts: &RerunOptions{
182 RunID: "1234",
183 },
184 httpStubs: func(reg *httpmock.Registry) {
185 reg.Register(
186 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
187 httpmock.JSONResponse(shared.FailedRun))
188 reg.Register(
189 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
190 httpmock.JSONResponse(workflowShared.WorkflowsPayload{
191 Workflows: []workflowShared.Workflow{
192 shared.TestWorkflow,
193 },
194 }))
195 reg.Register(
196 httpmock.REST("POST", "repos/OWNER/REPO/actions/runs/1234/rerun"),
197 httpmock.StringResponse("{}"))
198 },
199 wantOut: "✓ Requested rerun of run 1234\n",
200 },
201 {
202 name: "arg including onlyFailed",
203 tty: true,
204 opts: &RerunOptions{
205 RunID: "1234",
206 OnlyFailed: true,
207 },
208 httpStubs: func(reg *httpmock.Registry) {
209 reg.Register(
210 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/1234"),
211 httpmock.JSONResponse(shared.FailedRun))
212 reg.Register(
213 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
214 httpmock.JSONResponse(workflowShared.WorkflowsPayload{
215 Workflows: []workflowShared.Workflow{
216 shared.TestWorkflow,
217 },
218 }))
219 reg.Register(
220 httpmock.REST("POST", "repos/OWNER/REPO/actions/runs/1234/rerun-failed-jobs"),
221 httpmock.StringResponse("{}"))
222 },
223 wantOut: "✓ Requested rerun (failed jobs) of run 1234\n",

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
StringResponseFunction · 0.92
JSONErrorResponseFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
NewMockPrompterFunction · 0.92
runRerunFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80

Tested by

no test coverage detected