@@ -126,7 +126,7 @@ func TestImageListCheckTotalSize(t *testing.T) {
126
126
ctx = logtest .WithT (ctx , t )
127
127
service := fakeImageService (t , ctx , cs )
128
128
129
- _ , err = service .images .Create (ctx , imagesFromIndex (twoplatform )[0 ])
129
+ img , err : = service .images .Create (ctx , imagesFromIndex (twoplatform )[0 ])
130
130
assert .NilError (t , err )
131
131
132
132
all , err := service .Images (ctx , imagetypes.ListOptions {Manifests : true , SharedSize : true })
@@ -173,6 +173,32 @@ func TestImageListCheckTotalSize(t *testing.T) {
173
173
// TODO: This should also include the Size.Unpacked, but the test snapshotter doesn't do anything yet
174
174
assert .Check (t , is .Equal (all [0 ].Manifests [0 ].Size .Total , amd64ManifestSize + amd64ConfigSize + amd64LayerSize ))
175
175
assert .Check (t , is .Equal (all [0 ].Manifests [1 ].Size .Total , amd64ManifestSize + amd64ConfigSize + amd64LayerSize ))
176
+
177
+ t .Run ("without layers" , func (t * testing.T ) {
178
+ var layers []ocispec.Descriptor
179
+ err = service .walkPresentChildren (ctx , img .Target , func (ctx context.Context , desc ocispec.Descriptor ) error {
180
+ if c8dimages .IsLayerType (desc .MediaType ) {
181
+ layers = append (layers , desc )
182
+ }
183
+ return nil
184
+ })
185
+ assert .NilError (t , err )
186
+
187
+ for _ , layer := range layers {
188
+ err := cs .Delete (ctx , layer .Digest )
189
+ assert .NilError (t , err , "failed to delete layer %s" , layer .Digest )
190
+ }
191
+
192
+ all , err := service .Images (ctx , imagetypes.ListOptions {Manifests : true , SharedSize : true })
193
+ assert .NilError (t , err )
194
+
195
+ assert .Assert (t , is .Len (all , 1 ))
196
+ assert .Check (t , is .Equal (all [0 ].Size , allTotalSize - indexSize - arm64LayerSize - amd64LayerSize ))
197
+
198
+ assert .Assert (t , is .Len (all [0 ].Manifests , 2 ))
199
+ assert .Check (t , is .Equal (all [0 ].Manifests [0 ].Size .Content , arm64ManifestSize + arm64ConfigSize ))
200
+ assert .Check (t , is .Equal (all [0 ].Manifests [1 ].Size .Content , amd64ManifestSize + amd64ConfigSize ))
201
+ })
176
202
}
177
203
178
204
func blobSize (t * testing.T , ctx context.Context , cs content.Store , dgst digest.Digest ) int64 {
0 commit comments