(t *testing.T)
| 461 | } |
| 462 | |
| 463 | func 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": "", |
nothing calls this directly
no test coverage detected
searching dependent graphs…