@@ -475,6 +475,134 @@ func TestImageImages(t *testing.T) {
475475 },
476476 imageCnt : 1 ,
477477 },
478+ {
479+ name : "podman 5.6.1, fedora-toolbox:41, no name specified" ,
480+ data : "" +
481+ "[" +
482+ " {" +
483+ " \" Id\" : \" b65ee158f921088db52e8b98a6f3267de75324c8a6a04afc9ff095338c40e59b\" ," +
484+ " \" ParentId\" : \" \" ," +
485+ " \" RepoTags\" : null," +
486+ " \" RepoDigests\" : [" +
487+ " \" registry.fedoraproject.org/fedora-toolbox@sha256:0a51adc6bab55d49ff00da8aaad81ca1f02315511ed23d55ee5bbbe1a976a663\" ," +
488+ " \" registry.fedoraproject.org/fedora-toolbox@sha256:8599f0c0d421c0dc01c4b7fb1c07b2780c0ab1931d0f22dd7b6da3b93ff6b77b\" " +
489+ " ]," +
490+ " \" Size\" : 2308518290," +
491+ " \" SharedSize\" : 0," +
492+ " \" VirtualSize\" : 2308518290," +
493+ " \" Labels\" : {" +
494+ " \" com.github.containers.toolbox\" : \" true\" ," +
495+ " \" io.buildah.version\" : \" 1.41.4\" ," +
496+ " \" license\" : \" MIT\" ," +
497+ " \" name\" : \" fedora-toolbox\" ," +
498+ " \" org.opencontainers.image.license\" : \" MIT\" ," +
499+ " \" org.opencontainers.image.name\" : \" fedora-toolbox\" ," +
500+ " \" org.opencontainers.image.url\" : \" https://fedoraproject.org/\" ," +
501+ " \" org.opencontainers.image.vendor\" : \" Fedora Project\" ," +
502+ " \" org.opencontainers.image.version\" : \" 41\" ," +
503+ " \" vendor\" : \" Fedora Project\" ," +
504+ " \" version\" : \" 41\" " +
505+ " }," +
506+ " \" Containers\" : 1," +
507+ " \" Digest\" : \" sha256:0a51adc6bab55d49ff00da8aaad81ca1f02315511ed23d55ee5bbbe1a976a663\" ," +
508+ " \" History\" : [" +
509+ " \" registry.fedoraproject.org/fedora-toolbox:41\" " +
510+ " ]," +
511+ " \" Names\" : []," +
512+ " \" Created\" : 1759729685," +
513+ " \" CreatedAt\" : \" 2025-10-06T05:48:05Z\" " +
514+ " }" +
515+ "]" ,
516+ expects : []expect {
517+ {
518+ id : "b65ee158f921088db52e8b98a6f3267de75324c8a6a04afc9ff095338c40e59b" ,
519+ isToolbx : true ,
520+ labels : map [string ]string {
521+ "com.github.containers.toolbox" : "true" ,
522+ "io.buildah.version" : "1.41.4" ,
523+ "license" : "MIT" ,
524+ "name" : "fedora-toolbox" ,
525+ "org.opencontainers.image.license" : "MIT" ,
526+ "org.opencontainers.image.name" : "fedora-toolbox" ,
527+ "org.opencontainers.image.url" : "https://fedoraproject.org/" ,
528+ "org.opencontainers.image.vendor" : "Fedora Project" ,
529+ "org.opencontainers.image.version" : "41" ,
530+ "vendor" : "Fedora Project" ,
531+ "version" : "41" ,
532+ },
533+ names : []string {},
534+ repoTags : nil ,
535+ },
536+ },
537+ imageCnt : 1 ,
538+ },
539+ {
540+ name : "podman 5.6.1, fedora-toolbox:41, multiple names specified" ,
541+ data : "" +
542+ "[" +
543+ " {" +
544+ " \" Id\" : \" b65ee158f921088db52e8b98a6f3267de75324c8a6a04afc9ff095338c40e59b\" ," +
545+ " \" ParentId\" : \" \" ," +
546+ " \" RepoTags\" : null," +
547+ " \" RepoDigests\" : [" +
548+ " \" registry.fedoraproject.org/fedora-toolbox@sha256:0a51adc6bab55d49ff00da8aaad81ca1f02315511ed23d55ee5bbbe1a976a663\" ," +
549+ " \" registry.fedoraproject.org/fedora-toolbox@sha256:8599f0c0d421c0dc01c4b7fb1c07b2780c0ab1931d0f22dd7b6da3b93ff6b77b\" " +
550+ " ]," +
551+ " \" Size\" : 2308518290," +
552+ " \" SharedSize\" : 0," +
553+ " \" VirtualSize\" : 2308518290," +
554+ " \" Labels\" : {" +
555+ " \" com.github.containers.toolbox\" : \" true\" ," +
556+ " \" io.buildah.version\" : \" 1.41.4\" ," +
557+ " \" license\" : \" MIT\" ," +
558+ " \" name\" : \" fedora-toolbox\" ," +
559+ " \" org.opencontainers.image.license\" : \" MIT\" ," +
560+ " \" org.opencontainers.image.name\" : \" fedora-toolbox\" ," +
561+ " \" org.opencontainers.image.url\" : \" https://fedoraproject.org/\" ," +
562+ " \" org.opencontainers.image.vendor\" : \" Fedora Project\" ," +
563+ " \" org.opencontainers.image.version\" : \" 41\" ," +
564+ " \" vendor\" : \" Fedora Project\" ," +
565+ " \" version\" : \" 41\" " +
566+ " }," +
567+ " \" Containers\" : 1," +
568+ " \" Digest\" : \" sha256:0a51adc6bab55d49ff00da8aaad81ca1f02315511ed23d55ee5bbbe1a976a663\" ," +
569+ " \" History\" : [" +
570+ " \" registry.fedoraproject.org/fedora-toolbox:41\" " +
571+ " ]," +
572+ " \" Names\" : [" +
573+ " \" registry.fedoraproject.org/fedora-toolbox:41-test\" ," +
574+ " \" registry.fedoraproject.org/fedora-toolbox:41\" " +
575+ " ]," +
576+ " \" Created\" : 1759729685," +
577+ " \" CreatedAt\" : \" 2025-10-06T05:48:05Z\" " +
578+ " }" +
579+ "]" ,
580+ expects : []expect {
581+ {
582+ id : "b65ee158f921088db52e8b98a6f3267de75324c8a6a04afc9ff095338c40e59b" ,
583+ isToolbx : true ,
584+ labels : map [string ]string {
585+ "com.github.containers.toolbox" : "true" ,
586+ "io.buildah.version" : "1.41.4" ,
587+ "license" : "MIT" ,
588+ "name" : "fedora-toolbox" ,
589+ "org.opencontainers.image.license" : "MIT" ,
590+ "org.opencontainers.image.name" : "fedora-toolbox" ,
591+ "org.opencontainers.image.url" : "https://fedoraproject.org/" ,
592+ "org.opencontainers.image.vendor" : "Fedora Project" ,
593+ "org.opencontainers.image.version" : "41" ,
594+ "vendor" : "Fedora Project" ,
595+ "version" : "41" ,
596+ },
597+ names : []string {
598+ "registry.fedoraproject.org/fedora-toolbox:41-test" ,
599+ "registry.fedoraproject.org/fedora-toolbox:41" ,
600+ },
601+ repoTags : nil ,
602+ },
603+ },
604+ imageCnt : 1 ,
605+ },
478606 {
479607 name : "podman 5.6.2, fedora-toolbox:42, docker.io-postgres:18, fedora-toolbox:42-aarch64" ,
480608 data : "" +
@@ -644,6 +772,20 @@ func TestImageImages(t *testing.T) {
644772 assert .Equal (t , expect .labels , image .Labels ())
645773 assert .Equal (t , expect .names , image .Names ())
646774 assert .Equal (t , expect .repoTags , image .RepoTags ())
775+
776+ if len (expect .names ) == 1 {
777+ assert .Equal (t , expect .names [0 ], image .Name ())
778+ } else if len (expect .names ) > 1 {
779+ assert .Panics (t , func () { _ = image .Name () })
780+
781+ imagesFlattened := image .flattenNames (false )
782+ for j , imageFlattened := range imagesFlattened {
783+ assert .Equal (t , expect .names [j ], imageFlattened .Name ())
784+ }
785+
786+ } else {
787+ assert .Panics (t , func () { _ = image .Name () })
788+ }
647789 }
648790 })
649791 }
0 commit comments