(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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", |
nothing calls this directly
no test coverage detected
searching dependent graphs…