MCPcopy
hub / github.com/cli/cli / TestListRun

Function TestListRun

pkg/cmd/run/list/list_test.go:139–720  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestListRun(t *testing.T) {
140 tests := []struct {
141 name string
142 opts *ListOptions
143 wantErr bool
144 wantOut string
145 wantErrOut string
146 wantErrMsg string
147 stubs func(*httpmock.Registry)
148 isTTY bool
149 }{
150 {
151 name: "default arguments",
152 opts: &ListOptions{
153 Limit: defaultLimit,
154 now: shared.TestRunStartTime.Add(time.Minute*4 + time.Second*34),
155 },
156 isTTY: true,
157 stubs: func(reg *httpmock.Registry) {
158 reg.Register(
159 httpmock.REST("GET", "repos/OWNER/REPO/actions/runs"),
160 httpmock.JSONResponse(shared.RunsPayload{
161 WorkflowRuns: shared.TestRuns,
162 }))
163 reg.Register(
164 httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows"),
165 httpmock.JSONResponse(workflowShared.WorkflowsPayload{
166 Workflows: []workflowShared.Workflow{
167 shared.TestWorkflow,
168 },
169 }))
170 },
171 wantOut: heredoc.Doc(`
172 STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE
173 X cool commit CI trunk push 1 4m34s about 4 minutes ago
174 * cool commit CI trunk push 2 4m34s about 4 minutes ago
175 ✓ cool commit CI trunk push 3 4m34s about 4 minutes ago
176 X cool commit CI trunk push 4 4m34s about 4 minutes ago
177 X cool commit CI trunk push 1234 4m34s about 4 minutes ago
178 - cool commit CI trunk push 6 4m34s about 4 minutes ago
179 - cool commit CI trunk push 7 4m34s about 4 minutes ago
180 * cool commit CI trunk push 8 4m34s about 4 minutes ago
181 * cool commit CI trunk push 9 4m34s about 4 minutes ago
182 X cool commit CI trunk push 10 4m34s about 4 minutes ago
183 `),
184 },
185 {
186 name: "inactive disabled workflow selected",
187 opts: &ListOptions{
188 Limit: defaultLimit,
189 now: shared.TestRunStartTime.Add(time.Minute*4 + time.Second*34),
190 WorkflowSelector: "d. inact",
191 All: false,
192 },
193 isTTY: true,
194 stubs: func(reg *httpmock.Registry) {
195 // Uses abbreviated names and commit messages because of output column limit
196 workflow := workflowShared.Workflow{

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
StatusStringResponseFunction · 0.92
WithHeaderFunction · 0.92
QueryMatcherFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70

Tested by

no test coverage detected