(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func 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 | |
| 170 | Showing 2 of 2 caches in OWNER/REPO |
| 171 | |
| 172 | ID KEY SIZE CREATED ACCESSED |
| 173 | 1 foo 100 B about 2 years ago about 1 year ago |
| 174 | 2 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, |
nothing calls this directly
no test coverage detected