MCPcopy
hub / github.com/cli/cli / Test_listRun

Function Test_listRun

pkg/cmd/agent-task/list/list_test.go:92–403  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func Test_listRun(t *testing.T) {
93 sampleDate := time.Now().Add(-6 * time.Hour) // 6h ago
94 sampleDateString := sampleDate.Format(time.RFC3339)
95
96 tests := []struct {
97 name string
98 tty bool
99 capiStubs func(*testing.T, *capi.CapiClientMock)
100 limit int
101 web bool
102 jsonFields []string
103 wantOut string
104 wantErr error
105 wantStderr string
106 wantBrowserURL string
107 }{
108 {
109 name: "viewer-scoped no sessions",
110 tty: true,
111 capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
112 m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
113 return nil, nil
114 }
115 },
116 wantErr: cmdutil.NewNoResultsError("no agent tasks found"),
117 },
118 {
119 name: "viewer-scoped respects --limit",
120 tty: true,
121 limit: 999,
122 capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
123 m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
124 assert.Equal(t, 999, limit)
125 return nil, nil
126 }
127 },
128 wantErr: cmdutil.NewNoResultsError("no agent tasks found"), // not important
129 },
130 {
131 name: "viewer-scoped single session (tty)",
132 tty: true,
133 capiStubs: func(t *testing.T, m *capi.CapiClientMock) {
134 m.ListLatestSessionsForViewerFunc = func(ctx context.Context, limit int) ([]*capi.Session, error) {
135 return []*capi.Session{
136 {
137 ID: "id1",
138 Name: "s1",
139 State: "completed",
140 CreatedAt: sampleDate,
141 ResourceType: "pull",
142 PullRequest: &api.PullRequest{
143 Number: 101,
144 Repository: &api.PRRepository{
145 NameWithOwner: "OWNER/REPO",
146 },
147 },
148 },
149 }, nil

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
NewNoResultsErrorFunction · 0.92
TestFunction · 0.92
NewJSONExporterFunction · 0.92
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80
SetFieldsMethod · 0.80
listRunFunction · 0.70
AddMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected