MCPcopy
hub / github.com/cli/cli / TestGetWorkflows

Function TestGetWorkflows

pkg/cmd/workflow/shared/shared_test.go:304–407  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func 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),

Callers

nothing calls this directly

Calls 9

RegisterMethod · 0.95
NewFunction · 0.92
RESTFunction · 0.92
StatusJSONResponseFunction · 0.92
generateWorkflowsFunction · 0.85
GetWorkflowsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected