MCPcopy Index your code
hub / github.com/docker/cli / TestImageContext

Function TestImageContext

cli/command/formatter/image_test.go:16–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestImageContext(t *testing.T) {
17 imageID := test.RandomID()
18 unix := time.Now().Unix()
19 zeroTime := int64(-62135596800)
20
21 var ctx imageContext
22 cases := []struct {
23 imageCtx imageContext
24 expValue string
25 call func() string
26 }{
27 {
28 imageCtx: imageContext{i: image.Summary{ID: imageID}, trunc: true},
29 expValue: TruncateID(imageID),
30 call: ctx.ID,
31 },
32 {
33 imageCtx: imageContext{i: image.Summary{ID: imageID}, trunc: false},
34 expValue: imageID,
35 call: ctx.ID,
36 },
37 {
38 imageCtx: imageContext{i: image.Summary{Size: 10}, trunc: true},
39 expValue: "10B",
40 call: ctx.Size,
41 },
42 {
43 imageCtx: imageContext{i: image.Summary{Created: unix}, trunc: true},
44 expValue: time.Unix(unix, 0).String(), call: ctx.CreatedAt,
45 },
46 // FIXME
47 // {imageContext{
48 // i: image.Summary{Created: unix},
49 // trunc: true,
50 // }, units.HumanDuration(time.Unix(unix, 0)), createdSinceHeader, ctx.CreatedSince},
51 {
52 imageCtx: imageContext{i: image.Summary{}, repo: "busybox"},
53 expValue: "busybox",
54 call: ctx.Repository,
55 },
56 {
57 imageCtx: imageContext{i: image.Summary{}, tag: "latest"},
58 expValue: "latest",
59 call: ctx.Tag,
60 },
61 {
62 imageCtx: imageContext{i: image.Summary{}, digest: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a"},
63 expValue: "sha256:d149ab53f8718e987c3a3024bb8aa0e2caadf6c0328f1d9d850b2a2a67f2819a",
64 call: ctx.Digest,
65 },
66 {
67 imageCtx: imageContext{i: image.Summary{Containers: 10}},
68 expValue: "10",
69 call: ctx.Containers,
70 },
71 {
72 imageCtx: imageContext{i: image.Summary{SharedSize: 10000}},
73 expValue: "10kB",

Callers

nothing calls this directly

Calls 3

TruncateIDFunction · 0.85
ContainsMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…