(t *testing.T)
| 302 | } |
| 303 | |
| 304 | func TestGetWorkflows(t *testing.T) { |
| 305 | tests := []struct { |
| 306 | name string |
| 307 | repo ghrepo.Interface |
| 308 | limit int |
| 309 | httpStubs func(*httpmock.Registry) |
| 310 | expectedWorkflows []Workflow |
| 311 | expectedError error |
| 312 | }{ |
| 313 | { |
| 314 | name: "When the repo has no workflows, it returns an empty slice", |
| 315 | repo: ghrepo.New("OWNER", "REPO"), |
| 316 | httpStubs: func(reg *httpmock.Registry) { |
| 317 | reg.Register( |
| 318 | httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"), |
| 319 | httpmock.StatusJSONResponse(200, WorkflowsPayload{ |
| 320 | Workflows: []Workflow{}, |
| 321 | }), |
| 322 | ) |
| 323 | }, |
| 324 | expectedWorkflows: []Workflow{}, |
| 325 | }, |
| 326 | { |
| 327 | name: "When the api returns workflows, it returns those workflows", |
| 328 | repo: ghrepo.New("OWNER", "REPO"), |
| 329 | httpStubs: func(reg *httpmock.Registry) { |
| 330 | reg.Register( |
| 331 | httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"), |
| 332 | httpmock.StatusJSONResponse(200, WorkflowsPayload{ |
| 333 | Workflows: []Workflow{ |
| 334 | { |
| 335 | Name: "Workflow 1", |
| 336 | }, |
| 337 | { |
| 338 | Name: "Workflow 2", |
| 339 | }, |
| 340 | }, |
| 341 | }), |
| 342 | ) |
| 343 | }, |
| 344 | expectedWorkflows: []Workflow{ |
| 345 | { |
| 346 | Name: "Workflow 1", |
| 347 | }, |
| 348 | { |
| 349 | Name: "Workflow 2", |
| 350 | }, |
| 351 | }, |
| 352 | }, |
| 353 | { |
| 354 | name: "When the api return paginates, it returns the workflows from all the pages", |
| 355 | repo: ghrepo.New("OWNER", "REPO"), |
| 356 | limit: 0, |
| 357 | httpStubs: func(reg *httpmock.Registry) { |
| 358 | reg.Register( |
| 359 | httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"), |
| 360 | httpmock.StatusJSONResponse(200, WorkflowsPayload{ |
| 361 | Workflows: generateWorkflows(t, 100, 1), |
nothing calls this directly
no test coverage detected