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

Function TestContainerContextWriteJSON

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

Source from the content-addressed store, hash-verified

461}
462
463func TestContainerContextWriteJSON(t *testing.T) {
464 unix := time.Now().Add(-65 * time.Second).Unix()
465 containers := []container.Summary{
466 {
467 ID: "containerID1",
468 Names: []string{"/foobar_baz"},
469 Image: "ubuntu",
470 Created: unix,
471 State: container.StateRunning,
472 },
473 {
474 ID: "containerID2",
475 Names: []string{"/foobar_bar"},
476 Image: "ubuntu",
477 Created: unix,
478 State: container.StateRunning,
479
480 ImageManifestDescriptor: &ocispec.Descriptor{Platform: &ocispec.Platform{Architecture: "amd64", OS: "linux"}},
481 },
482 {
483 ID: "containerID3",
484 Names: []string{"/foobar_bar"},
485 Image: "ubuntu",
486 Created: unix,
487 State: container.StateRunning,
488
489 ImageManifestDescriptor: &ocispec.Descriptor{Platform: &ocispec.Platform{}},
490 },
491 }
492 expectedCreated := time.Unix(unix, 0).String()
493 expectedJSONs := []map[string]any{
494 {
495 "Command": `""`,
496 "CreatedAt": expectedCreated,
497 "HealthStatus": "",
498 "ID": "containerID1",
499 "Image": "ubuntu",
500 "Labels": "",
501 "LocalVolumes": "0",
502 "Mounts": "",
503 "Names": "foobar_baz",
504 "Networks": "",
505 "Platform": nil,
506 "Ports": "",
507 "RunningFor": "About a minute ago",
508 "Size": "0B",
509 "State": "running",
510 "Status": "",
511 },
512 {
513 "Command": `""`,
514 "CreatedAt": expectedCreated,
515 "HealthStatus": "",
516 "ID": "containerID2",
517 "Image": "ubuntu",
518 "Labels": "",
519 "LocalVolumes": "0",
520 "Mounts": "",

Callers

nothing calls this directly

Calls 2

ContainerWriteFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…