Repository: cli/cli
File: pkg/cmd/run/list/list_test.go (Go)

Code before:
					httpmock.JSONResponse(shared.RunsPayload{
						WorkflowRuns: shared.TestRuns,
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(workflowShared.WorkflowsPayload{
						Workflows: []workflowShared.Workflow{
							shared.TestWorkflow,
						},
					}))
			},
			wantOut: heredoc.Doc(`
				completed	timed_out	cool commit	CI	trunk	push	1	4m34s	2021-02-23T04:51:00Z
				in_progress		cool commit	CI	trunk	push	2	4m34s	2021-02-23T04:51:00Z
				completed	success	cool commit	CI	trunk	push	3	4m34s	2021-02-23T04:51:00Z
				completed	cancelled	cool commit	CI	trunk	push	4	4m34s	2021-02-23T04:51:00Z
				completed	failure	cool commit	CI	trunk	push	1234	4m34s	2021-02-23T04:51:00Z
				completed	neutral	cool commit	CI	trunk	push	6	4m34s	2021-02-23T04:51:00Z
				completed	skipped	cool commit	CI	trunk	push	7	4m34s	2021-02-23T04:51:00Z
				requested		cool commit	CI	trunk	push	8	4m34s	2021-02-23T04:51:00Z
				queued		cool commit	CI	trunk	push	9	4m34s	2021-02-23T04:51:00Z
				completed	stale	cool commit	CI	trunk	push	10	4m34s	2021-02-23T04:51:00Z
			`),
		},
		{
			name: "org required workflow in runs list shows with empty workflow name",
			opts: &ListOptions{
				Limit: defaultLimit,
				now:   shared.TestRunStartTime.Add(time.Minute*4 + time.Second*34),
			},
			isTTY: true,
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
					httpmock.JSONResponse(shared.RunsPayload{
						WorkflowRuns: shared.TestRunsWithOrgRequiredWorkflows,
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(workflowShared.WorkflowsPayload{
						Workflows: []workflowShared.Workflow{
							shared.TestWorkflow,
						},
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/456"),
					httpmock.StatusStringResponse(404, "not found"),
				)
			},
			wantOut: heredoc.Doc(`
				STATUS  TITLE        WORKFLOW  BRANCH  EVENT  ID  ELAPSED  AGE

Review comment (suggestion):
**question:** since enterprise ruleset workflows can create runs, should there be an enterprise case?

```suggestion
			name: "org ruleset workflow in runs list shows with empty workflow name",
```

Code after:
					httpmock.JSONResponse(shared.RunsPayload{
						WorkflowRuns: shared.TestRuns,
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(workflowShared.WorkflowsPayload{
						Workflows: []workflowShared.Workflow{
							shared.TestWorkflow,
						},
					}))
			},
			wantOut: heredoc.Doc(`
				completed	timed_out	cool commit	CI	trunk	push	1	4m34s	2021-02-23T04:51:00Z
				in_progress		cool commit	CI	trunk	push	2	4m34s	2021-02-23T04:51:00Z
				completed	success	cool commit	CI	trunk	push	3	4m34s	2021-02-23T04:51:00Z
				completed	cancelled	cool commit	CI	trunk	push	4	4m34s	2021-02-23T04:51:00Z
				completed	failure	cool commit	CI	trunk	push	1234	4m34s	2021-02-23T04:51:00Z
				completed	neutral	cool commit	CI	trunk	push	6	4m34s	2021-02-23T04:51:00Z
				completed	skipped	cool commit	CI	trunk	push	7	4m34s	2021-02-23T04:51:00Z
				requested		cool commit	CI	trunk	push	8	4m34s	2021-02-23T04:51:00Z
				queued		cool commit	CI	trunk	push	9	4m34s	2021-02-23T04:51:00Z
				completed	stale	cool commit	CI	trunk	push	10	4m34s	2021-02-23T04:51:00Z
			`),
		},
		{
			name: "org ruleset workflow in runs list shows with empty workflow name",
			opts: &ListOptions{
				Limit: defaultLimit,
				now:   shared.TestRunStartTime.Add(time.Minute*4 + time.Second*34),
			},
			isTTY: true,
			stubs: func(reg *httpmock.Registry) {
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
					httpmock.JSONResponse(shared.RunsPayload{
						WorkflowRuns: shared.TestRunsWithOrgRequiredWorkflows,
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
					httpmock.JSONResponse(workflowShared.WorkflowsPayload{
						Workflows: []workflowShared.Workflow{
							shared.TestWorkflow,
						},
					}))
				reg.Register(
					httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/456"),
					httpmock.StatusStringResponse(404, "not found"),
				)
			},
			wantOut: heredoc.Doc(`
				STATUS  TITLE        WORKFLOW  BRANCH  EVENT  ID  ELAPSED  AGE