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

Function TestListRun

pkg/cmd/cache/list/list_test.go:129–350  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestListRun(t *testing.T) {
130 var now = time.Date(2023, 1, 1, 1, 1, 1, 1, time.UTC)
131 tests := []struct {
132 name string
133 opts ListOptions
134 stubs func(*httpmock.Registry)
135 tty bool
136 wantErr bool
137 wantErrMsg string
138 wantStderr string
139 wantStdout string
140 }{
141 {
142 name: "displays results tty",
143 tty: true,
144 stubs: func(reg *httpmock.Registry) {
145 reg.Register(
146 httpmock.REST("GET", "repos/OWNER/REPO/actions/caches"),
147 httpmock.JSONResponse(shared.CachePayload{
148 ActionsCaches: []shared.Cache{
149 {
150 Id: 1,
151 Key: "foo",
152 CreatedAt: time.Date(2021, 1, 1, 1, 1, 1, 1, time.UTC),
153 LastAccessedAt: time.Date(2022, 1, 1, 1, 1, 1, 1, time.UTC),
154 SizeInBytes: 100,
155 },
156 {
157 Id: 2,
158 Key: "bar",
159 CreatedAt: time.Date(2021, 1, 1, 1, 1, 1, 1, time.UTC),
160 LastAccessedAt: time.Date(2022, 1, 1, 1, 1, 1, 1, time.UTC),
161 SizeInBytes: 1024,
162 },
163 },
164 TotalCount: 2,
165 }),
166 )
167 },
168 wantStdout: heredoc.Doc(`
169
170Showing 2 of 2 caches in OWNER/REPO
171
172ID KEY SIZE CREATED ACCESSED
1731 foo 100 B about 2 years ago about 1 year ago
1742 bar 1.00 KiB about 2 years ago about 1 year ago
175`),
176 },
177 {
178 name: "displays results non-tty",
179 tty: false,
180 stubs: func(reg *httpmock.Registry) {
181 reg.Register(
182 httpmock.REST("GET", "repos/OWNER/REPO/actions/caches"),
183 httpmock.JSONResponse(shared.CachePayload{
184 ActionsCaches: []shared.Cache{
185 {
186 Id: 1,

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
JSONResponseFunction · 0.92
StatusStringResponseFunction · 0.92
TestFunction · 0.92
NewFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
listRunFunction · 0.70

Tested by

no test coverage detected