MCPcopy Create free account
hub / github.com/cli/cli / TestListRun

Function TestListRun

pkg/cmd/issue/artifact/list/list_test.go:205–674  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

203}
204
205func TestListRun(t *testing.T) {
206 now := time.Date(2026, 9, 24, 23, 0, 0, 0, time.UTC)
207 hoursAgo := func(h int) *time.Time {
208 t := now.Add(-time.Duration(h) * time.Hour)
209 return &t
210 }
211
212 // The artifacts on the spec's issue 142.
213 const issuePage = "https://github.com/monalisa/monas-cafe/issues/142"
214 oauthPlan := client.Artifact{ID: 6626, Number: 2, Type: "generic", Name: "OAuth callback plan", UpdatedAt: hoursAgo(2), URL: issuePage + "/artifacts/2"}
215 runbook := client.Artifact{ID: 6627, Number: 3, Type: "link", Name: "Staging OAuth runbook", UpdatedAt: hoursAgo(24), URL: issuePage + "/artifacts/3"}
216 feedback := client.Artifact{ID: 6629, Number: 5, Type: "generic", Name: "Barista feedback notes", UpdatedAt: hoursAgo(72), URL: issuePage + "/artifacts/5"}
217 // The documents on the spec's issue 137.
218 approvedPlan := client.Artifact{ID: 6640, Number: 1, Type: "plan", Name: "Approved plan", UpdatedAt: hoursAgo(5)}
219 research := client.Artifact{ID: 6641, Number: 2, Type: "generic", Name: "OAuth provider research", UpdatedAt: hoursAgo(1)}
220 // The HTML document on the spec's issue 166.
221 menuPrototype := client.Artifact{ID: 6650, Number: 1, Type: "embedded_html", Name: "Menu prototype", UpdatedAt: hoursAgo(1)}
222
223 jsonExporter := func(fields ...string) cmdutil.Exporter {
224 e := cmdutil.NewJSONExporter()
225 e.SetFields(fields)
226 return e
227 }
228
229 // A pager command with an unterminated quote fails before any process
230 // starts, so a row can see whether list started the pager.
231 const brokenPager = "'"
232
233 tests := []struct {
234 name string
235 repo ghrepo.Interface
236 opts ListOptions
237 tty bool
238 pager string
239 isPullRequest bool
240 lookupErr error
241 artifacts map[string][]client.Artifact
242 listErrs map[string]error
243 wantCalls []string
244 wantStdout string
245 wantStderr string
246 wantErr string
247 wantNoResults bool
248 }{
249 {
250 name: "a table in a terminal",
251 opts: ListOptions{IssueNumber: 142},
252 tty: true,
253 artifacts: map[string][]client.Artifact{"": {oauthPlan, runbook, feedback}},
254 wantCalls: []string{
255 "IsPullRequest monalisa/monas-cafe#142",
256 `List monalisa/monas-cafe#142 type="" limit=0`,
257 },
258 wantStdout: heredoc.Doc(`
259
260 Showing 3 artifacts on monalisa/monas-cafe#142
261
262 NUMBER NAME TYPE UPDATED

Callers

nothing calls this directly

Calls 15

NewJSONExporterFunction · 0.92
NewWithHostFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
FullNameFunction · 0.92
DurationMethod · 0.80
SetFieldsMethod · 0.80
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
SetPagerMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected