@@ -439,7 +439,18 @@ func TestContainerContextWriteJSON(t *testing.T) {
439439 Image : "ubuntu" ,
440440 Created : unix ,
441441 State : container .StateRunning ,
442-
442+ NetworkSettings : & container.NetworkSettingsSummary {
443+ Networks : map [string ]* network.EndpointSettings {
444+ "bridge" : {
445+ IPAddress : "172.17.0.1" ,
446+ GlobalIPv6Address : "ff02::1" ,
447+ },
448+ "my-net" : {
449+ IPAddress : "172.18.0.1" ,
450+ GlobalIPv6Address : "ff02::2" ,
451+ },
452+ },
453+ },
443454 ImageManifestDescriptor : & ocispec.Descriptor {Platform : & ocispec.Platform {Architecture : "amd64" , OS : "linux" }},
444455 },
445456 {
@@ -458,6 +469,7 @@ func TestContainerContextWriteJSON(t *testing.T) {
458469 "Command" : `""` ,
459470 "CreatedAt" : expectedCreated ,
460471 "ID" : "containerID1" ,
472+ "IPAddresses" : []any {},
461473 "Image" : "ubuntu" ,
462474 "Labels" : "" ,
463475 "LocalVolumes" : "0" ,
@@ -472,15 +484,21 @@ func TestContainerContextWriteJSON(t *testing.T) {
472484 "Status" : "" ,
473485 },
474486 {
475- "Command" : `""` ,
476- "CreatedAt" : expectedCreated ,
477- "ID" : "containerID2" ,
487+ "Command" : `""` ,
488+ "CreatedAt" : expectedCreated ,
489+ "ID" : "containerID2" ,
490+ "IPAddresses" : []any {
491+ map [string ]any {"IP" : "172.17.0.1" , "Network" : "bridge" },
492+ map [string ]any {"IP" : "ff02::1" , "Network" : "bridge" },
493+ map [string ]any {"IP" : "172.18.0.1" , "Network" : "my-net" },
494+ map [string ]any {"IP" : "ff02::2" , "Network" : "my-net" },
495+ },
478496 "Image" : "ubuntu" ,
479497 "Labels" : "" ,
480498 "LocalVolumes" : "0" ,
481499 "Mounts" : "" ,
482500 "Names" : "foobar_bar" ,
483- "Networks" : "" ,
501+ "Networks" : "bridge,my-net " ,
484502 "Platform" : map [string ]any {"architecture" : "amd64" , "os" : "linux" },
485503 "Ports" : "" ,
486504 "RunningFor" : "About a minute ago" ,
@@ -492,6 +510,7 @@ func TestContainerContextWriteJSON(t *testing.T) {
492510 "Command" : `""` ,
493511 "CreatedAt" : expectedCreated ,
494512 "ID" : "containerID3" ,
513+ "IPAddresses" : []any {},
495514 "Image" : "ubuntu" ,
496515 "Labels" : "" ,
497516 "LocalVolumes" : "0" ,
@@ -564,8 +583,8 @@ func TestContainerContextIPAddresses(t *testing.T) {
564583 out := bytes .NewBufferString ("" )
565584 err := ContainerWrite (Context {Format : "{{.IPAddresses}}" , Output : out }, containers )
566585 assert .NilError (t , err )
567- assert .Equal (t , out .String (), `[one: 192.168.1.2 two: 192.168.178.2]
568- [one: 192.168.1.3 two: 192.168.178.3]
586+ assert .Equal (t , out .String (), `[one/ 192.168.1.2 two/ 192.168.178.2]
587+ [one/ 192.168.1.3 two/ 192.168.178.3]
569588` )
570589}
571590
0 commit comments