(t *testing.T)
| 194 | } |
| 195 | |
| 196 | func TestHistoryContext_Table(t *testing.T) { |
| 197 | out := bytes.NewBufferString("") |
| 198 | unixTime := time.Now().AddDate(0, 0, -1).Unix() |
| 199 | oldDate := time.Now().AddDate(-17, 0, 0).Unix() |
| 200 | histories := client.ImageHistoryResult{ |
| 201 | Items: []image.HistoryResponseItem{ |
| 202 | { |
| 203 | ID: "imageID1", |
| 204 | Created: unixTime, |
| 205 | CreatedBy: "/bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on", |
| 206 | Size: int64(182964289), |
| 207 | Comment: "Hi", |
| 208 | Tags: []string{"image:tag2"}, |
| 209 | }, |
| 210 | {ID: "imageID2", Created: unixTime, CreatedBy: "/bin/bash echo", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}}, |
| 211 | {ID: "imageID3", Created: unixTime, CreatedBy: "/bin/bash ls", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}}, |
| 212 | {ID: "imageID4", Created: unixTime, CreatedBy: "/bin/bash grep", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}}, |
| 213 | {ID: "imageID5", Created: 0, CreatedBy: "/bin/bash echo", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}}, |
| 214 | {ID: "imageID6", Created: oldDate, CreatedBy: "/bin/bash echo", Size: int64(182964289), Comment: "Hi", Tags: []string{"image:tag2"}}, |
| 215 | }, |
| 216 | } |
| 217 | |
| 218 | //nolint:dupword // ignore "Duplicate words (CREATED) found" |
| 219 | const expectedNoTrunc = `IMAGE CREATED CREATED BY SIZE COMMENT |
| 220 | imageID1 24 hours ago /bin/bash ls && npm i && npm run test && karma -c karma.conf.js start && npm start && more commands here && the list goes on 183MB Hi |
| 221 | imageID2 24 hours ago /bin/bash echo 183MB Hi |
| 222 | imageID3 24 hours ago /bin/bash ls 183MB Hi |
| 223 | imageID4 24 hours ago /bin/bash grep 183MB Hi |
| 224 | imageID5 N/A /bin/bash echo 183MB Hi |
| 225 | imageID6 17 years ago /bin/bash echo 183MB Hi |
| 226 | ` |
| 227 | //nolint:dupword // ignore "Duplicate words (CREATED) found" |
| 228 | const expectedTrunc = `IMAGE CREATED CREATED BY SIZE COMMENT |
| 229 | imageID1 24 hours ago /bin/bash ls && npm i && npm run test && kar… 183MB Hi |
| 230 | imageID2 24 hours ago /bin/bash echo 183MB Hi |
| 231 | imageID3 24 hours ago /bin/bash ls 183MB Hi |
| 232 | imageID4 24 hours ago /bin/bash grep 183MB Hi |
| 233 | imageID5 N/A /bin/bash echo 183MB Hi |
| 234 | imageID6 17 years ago /bin/bash echo 183MB Hi |
| 235 | ` |
| 236 | |
| 237 | cases := []struct { |
| 238 | context formatter.Context |
| 239 | expected string |
| 240 | }{ |
| 241 | { |
| 242 | formatter.Context{ |
| 243 | Format: newHistoryFormat("table", false, true), |
| 244 | Trunc: true, |
| 245 | Output: out, |
| 246 | }, |
| 247 | expectedTrunc, |
| 248 | }, |
| 249 | { |
| 250 | formatter.Context{ |
| 251 | Format: newHistoryFormat("table", false, true), |
| 252 | Trunc: false, |
| 253 | Output: out, |
nothing calls this directly
no test coverage detected
searching dependent graphs…