@@ -382,11 +382,21 @@ func ensurePackageCacheCleanup(t *testing.T, imageConnection *imageconnection.Im
382382 baseImageInfo testBaseImageInfo ,
383383) {
384384 t .Helper ()
385- if baseImageInfo .Distro == baseImageDistroUbuntu {
385+ switch baseImageInfo .Distro {
386+ case baseImageDistroUbuntu :
386387 ensureAptCacheCleanup (t , imageConnection )
387388 ensureAptServicePreventionRestored (t , imageConnection )
388- } else {
389- ensureTdnfCacheCleanup (t , imageConnection , "/var/cache/tdnf" , baseImageInfo )
389+ case baseImageDistroAzureLinux :
390+ switch baseImageInfo .Version {
391+ case baseImageVersionAzl2 , baseImageVersionAzl3 :
392+ ensureRpmCacheCleanup (t , imageConnection , "/var/cache/tdnf" , baseImageInfo )
393+ case baseImageVersionAzl4 :
394+ ensureRpmCacheCleanup (t , imageConnection , "/var/cache/dnf" , baseImageInfo )
395+ default :
396+ t .Fatalf ("unsupported Azure Linux version for cache cleanup: %s" , baseImageInfo .Version )
397+ }
398+ default :
399+ t .Fatalf ("unsupported distro for cache cleanup: %s" , baseImageInfo .Distro )
390400 }
391401}
392402
@@ -558,7 +568,7 @@ func testCustomizeImagePackagesBadRepoHelper(t *testing.T, baseImageInfo testBas
558568 assert .ErrorIs (t , err , ErrPackageRepoMetadataRefresh )
559569}
560570
561- func ensureTdnfCacheCleanup (t * testing.T , imageConnection * imageconnection.ImageConnection , dirPath string ,
571+ func ensureRpmCacheCleanup (t * testing.T , imageConnection * imageconnection.ImageConnection , dirPath string ,
562572 baseImageInfo testBaseImageInfo ,
563573) {
564574 // Array to capture all the files of the provided root directory
0 commit comments