cli/formatter: reformat TestImageContext test cases

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-07-10 16:00:11 +02:00
parent d642de78f3
commit 0c2fe385bf
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 49 additions and 43 deletions

View File

@ -25,63 +25,69 @@ func TestImageContext(t *testing.T) {
expValue string
call func() string
}{
{imageContext{
i: types.ImageSummary{ID: imageID},
trunc: true,
}, stringid.TruncateID(imageID), ctx.ID},
{imageContext{
i: types.ImageSummary{ID: imageID},
trunc: false,
}, imageID, ctx.ID},
{imageContext{
i: types.ImageSummary{Size: 10, VirtualSize: 10},
trunc: true,
}, "10B", ctx.Size},
{imageContext{
i: types.ImageSummary{Created: unix},
trunc: true,
}, time.Unix(unix, 0).String(), ctx.CreatedAt},
{
imageCtx: imageContext{i: types.ImageSummary{ID: imageID}, trunc: true},
expValue: stringid.TruncateID(imageID),
call: ctx.ID,
},
{
imageCtx: imageContext{i: types.ImageSummary{ID: imageID}, trunc: false},
expValue: imageID,
call: ctx.ID,
},
{
imageCtx: imageContext{i: types.ImageSummary{Size: 10, VirtualSize: 10}, trunc: true},
expValue: "10B",
call: ctx.Size,
},
{
imageCtx: imageContext{i: types.ImageSummary{Created: unix}, trunc: true},
expValue: time.Unix(unix, 0).String(), call: ctx.CreatedAt,
},
// FIXME
// {imageContext{
// i: types.ImageSummary{Created: unix},
// trunc: true,
// }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince},
{imageContext{
i: types.ImageSummary{},
repo: "busybox",
}, "busybox", ctx.Repository},
{imageContext{
i: types.ImageSummary{},
tag: "latest",
}, "latest", ctx.Tag},
{imageContext{
i: types.ImageSummary{},
digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
}, "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a", ctx.Digest},
{
imageContext{
i: types.ImageSummary{Containers: 10},
}, "10", ctx.Containers,
imageCtx: imageContext{i: types.ImageSummary{}, repo: "busybox"},
expValue: "busybox",
call: ctx.Repository,
},
{
imageContext{
i: types.ImageSummary{VirtualSize: 10000},
}, "10kB", ctx.VirtualSize,
imageCtx: imageContext{i: types.ImageSummary{}, tag: "latest"},
expValue: "latest",
call: ctx.Tag,
},
{
imageContext{
i: types.ImageSummary{SharedSize: 10000},
}, "10kB", ctx.SharedSize,
imageCtx: imageContext{i: types.ImageSummary{}, digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a"},
expValue: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
call: ctx.Digest,
},
{
imageContext{
i: types.ImageSummary{SharedSize: 5000, VirtualSize: 20000},
}, "15kB", ctx.UniqueSize,
imageCtx: imageContext{i: types.ImageSummary{Containers: 10}},
expValue: "10",
call: ctx.Containers,
},
{
imageContext{
i: types.ImageSummary{Created: zeroTime},
}, "", ctx.CreatedSince,
imageCtx: imageContext{i: types.ImageSummary{VirtualSize: 10000}},
expValue: "10kB",
call: ctx.VirtualSize,
},
{
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 10000}},
expValue: "10kB",
call: ctx.SharedSize,
},
{
imageCtx: imageContext{i: types.ImageSummary{SharedSize: 5000, VirtualSize: 20000}},
expValue: "15kB",
call: ctx.UniqueSize,
},
{
imageCtx: imageContext{i: types.ImageSummary{Created: zeroTime}},
expValue: "",
call: ctx.CreatedSince,
},
}