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

Function TestContainerPsContext

cli/command/formatter/container_test.go:23–258  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestContainerPsContext(t *testing.T) {
24 containerID := test.RandomID()
25 unix := time.Now().Add(-65 * time.Second).Unix()
26
27 var ctx ContainerContext
28 cases := []struct {
29 container container.Summary
30 trunc bool
31 expValue string
32 call func() string
33 }{
34 {
35 container: container.Summary{ID: containerID},
36 trunc: true,
37 expValue: TruncateID(containerID),
38 call: ctx.ID,
39 },
40 {
41 container: container.Summary{ID: containerID},
42 expValue: containerID,
43 call: ctx.ID,
44 },
45 {
46 container: container.Summary{Names: []string{"/foobar_baz"}},
47 trunc: true,
48 expValue: "foobar_baz",
49 call: ctx.Names,
50 },
51 {
52 container: container.Summary{Image: "ubuntu"},
53 trunc: true,
54 expValue: "ubuntu",
55 call: ctx.Image,
56 },
57 {
58 container: container.Summary{Image: "ubuntu:latest"},
59 trunc: true,
60 expValue: "ubuntu:latest",
61 call: ctx.Image,
62 },
63 {
64 container: container.Summary{Image: "docker.io/library/ubuntu"},
65 trunc: true,
66 expValue: "ubuntu",
67 call: ctx.Image,
68 },
69 {
70 container: container.Summary{Image: "docker.io/library/ubuntu:latest"},
71 trunc: true,
72 expValue: "ubuntu:latest",
73 call: ctx.Image,
74 },
75 {
76 container: container.Summary{Image: "ubuntu:latest@sha256:a5a665ff33eced1e0803148700880edab4269067ed77e27737a708d0d293fbf5"},
77 trunc: true,
78 expValue: "ubuntu:latest",
79 call: ctx.Image,
80 },

Callers

nothing calls this directly

Calls 4

LabelMethod · 0.95
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…