mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user