chore: stabilize coverage for specific imagestore case (#3429)

https://app.codecov.io/gh/project-zot/zot/commit/636a6b1820088c4334b02ef5d2e61a3450c4b231/indirect-changes

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2025-10-05 09:40:25 +03:00
committed by GitHub
parent 50c7fa6dd8
commit cbbd39745c
+27
View File
@@ -3212,6 +3212,33 @@ func NewRandomImgManifest(data []byte, cdigest, ldigest godigest.Digest, cblob,
return &manifest, nil
}
func TestGetNextDigestWithBlobPathsPathNotFound(t *testing.T) {
Convey("GetNextDigestWithBlobPaths PathNotFoundError handling", t, func() {
dir := t.TempDir()
log := zlog.NewTestLogger()
metrics := monitoring.NewMetricsServer(false, log)
cacheDriver, _ := storage.Create("boltdb", cache.BoltDBDriverParameters{
RootDir: dir,
Name: "cache",
UseRelPaths: true,
}, log)
imgStore := local.NewImageStore(dir, true, true, log, metrics, nil, cacheDriver, nil, nil)
// Remove the root directory to trigger PathNotFoundError
err := os.RemoveAll(imgStore.RootDir())
So(err, ShouldBeNil)
// Call GetNextDigestWithBlobPaths - should handle PathNotFoundError gracefully
digest, duplicateBlobs, err := imgStore.GetNextDigestWithBlobPaths([]string{"test-repo"}, []godigest.Digest{})
// Should return empty digest, empty duplicateBlobs, and no error
So(digest.String(), ShouldEqual, "")
So(duplicateBlobs, ShouldBeEmpty)
So(err, ShouldBeNil)
})
}
func newRandomBlobForFuzz(data []byte) (godigest.Digest, []byte, error) { //nolint:unparam
return godigest.FromBytes(data), data, nil
}