(t *testing.T)
| 164 | } |
| 165 | |
| 166 | func 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", |
nothing calls this directly
no test coverage detected