@@ -125,6 +125,40 @@ func TestRemoveCmd_NotFound(t *testing.T) {
125125 }
126126}
127127
128+ // TestRemoveCmd_ContainerdImageName confirms that a
129+ // registry-prefixed ref (which only appears in the io.containerd.image.name
130+ // annotation, not the registry-stripped org.opencontainers.image.ref.name
131+ // used to key the store's nameMap) still matches for removal.
132+ func TestRemoveCmd_ContainerdImageName (t * testing.T ) {
133+ ctx := newTestContext (t )
134+ s := newTestStore (t )
135+ host , rOpts := newLocalhostRegistry (t )
136+ seedImage (t , host , "test/repo" , "v1" , rOpts ... )
137+
138+ rso := defaultRootOpts (s .Root )
139+ ro := defaultCliOpts ()
140+
141+ if err := storeImage (ctx , s , v1.Image {Name : host + "/test/repo:v1" }, "" , false , rso , ro , "" ); err != nil {
142+ t .Fatalf ("storeImage: %v" , err )
143+ }
144+
145+ if n := countArtifactsInStore (t , s ); n == 0 {
146+ t .Fatal ("expected at least 1 artifact after storeImage, got 0" )
147+ }
148+
149+ // The registry-qualified ref only lives in io.containerd.image.name;
150+ // org.opencontainers.image.ref.name (and the nameMap key derived from it)
151+ // only holds the registry-stripped short form "test/repo:v1".
152+ fullRef := host + "/test/repo:v1"
153+ if err := RemoveCmd (ctx , & flags.RemoveOpts {Force : true }, s , fullRef ); err != nil {
154+ t .Fatalf ("RemoveCmd with fully-qualified ref: %v" , err )
155+ }
156+
157+ if n := countArtifactsInStore (t , s ); n != 0 {
158+ t .Errorf ("expected 0 artifacts after removal by containerd image name, got %d" , n )
159+ }
160+ }
161+
128162func TestRemoveCmd_Force_MultipleMatches (t * testing.T ) {
129163 ctx := newTestContext (t )
130164 s := newTestStore (t )
0 commit comments