MCPcopy Index your code
hub / github.com/cli/cli / TestRenderJobs

Function TestRenderJobs

pkg/cmd/run/shared/presentation_test.go:13–398  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestRenderJobs(t *testing.T) {
14 startedAt, err := time.Parse(time.RFC3339, "2009-03-19T00:00:00Z")
15 require.NoError(t, err)
16 completedAt, err := time.Parse(time.RFC3339, "2009-03-19T00:01:00Z")
17 require.NoError(t, err)
18
19 tests := []struct {
20 name string
21 jobs []Job
22 wantVerbose string
23 wantNormal string
24 wantCompact string
25 }{
26 {
27 name: "nil jobs",
28 jobs: nil,
29 },
30 {
31 name: "empty jobs",
32 jobs: []Job{},
33 },
34 {
35 // This is not a real-world case, but nevertheless the code should
36 // be able to handle that without error/panic.
37 name: "in-progress job without steps",
38 jobs: []Job{
39 {
40 Name: "foo",
41 ID: 999,
42 StartedAt: startedAt,
43 Status: InProgress,
44 },
45 },
46 wantCompact: heredoc.Doc(`
47 * foo (ID 999)`),
48 wantNormal: heredoc.Doc(`
49 * foo (ID 999)`),
50 wantVerbose: heredoc.Doc(`
51 * foo (ID 999)`),
52 },
53 {
54 // This is not a real-world case, but nevertheless the code should
55 // be able to handle that without error/panic.
56 name: "successful job without steps",
57 jobs: []Job{
58 {
59 Name: "foo",
60 ID: 999,
61 StartedAt: startedAt,
62 CompletedAt: completedAt,
63 Status: Completed,
64 Conclusion: Success,
65 },
66 },
67 wantCompact: heredoc.Doc(`
68 ✓ foo in 1m0s (ID 999)`),
69 wantNormal: heredoc.Doc(`
70 ✓ foo in 1m0s (ID 999)`),

Callers

nothing calls this directly

Calls 4

RenderJobsCompactFunction · 0.85
RenderJobsFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected