formatters(image): prevent image size from displaying scientific notation

This commit is contained in:
Nate 2024-05-05 15:54:50 -04:00 committed by GitHub
parent 647ccf3433
commit a418c68e38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -248,7 +248,7 @@ func (c *imageContext) CreatedAt() string {
}
func (c *imageContext) Size() string {
return units.HumanSizeWithPrecision(float64(c.i.Size), 3)
return units.HumanSize(float64(c.i.Size))
}
func (c *imageContext) Containers() string {

View File

@ -40,6 +40,11 @@ func TestImageContext(t *testing.T) {
expValue: "10B",
call: ctx.Size,
},
{
imageCtx: imageContext{i: types.ImageSummary{Size: 999900000}, trunc: true},
expValue: "999.9MB",
call: ctx.Size,
},
{
imageCtx: imageContext{i: image.Summary{Created: unix}, trunc: true},
expValue: time.Unix(unix, 0).String(), call: ctx.CreatedAt,