From cbbd39745c5d569a941629725a6036ac182b115c Mon Sep 17 00:00:00 2001 From: Andrei Aaron Date: Sun, 5 Oct 2025 09:40:25 +0300 Subject: [PATCH] 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 --- pkg/storage/local/local_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/storage/local/local_test.go b/pkg/storage/local/local_test.go index d49429a3..acd67712 100644 --- a/pkg/storage/local/local_test.go +++ b/pkg/storage/local/local_test.go @@ -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 }