mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
fix(npe): handle case where os.Stat returns different error types in DirExists (#2253)
See https://github.com/project-zot/zot/actions/runs/7905369535/job/21577848110 Also add tests to fix some of the coverage fluctuations. Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -25,6 +25,8 @@ import (
|
||||
"zotregistry.dev/zot/pkg/test/mocks"
|
||||
)
|
||||
|
||||
var ErrTestError = errors.New("TestError")
|
||||
|
||||
func TestValidateManifest(t *testing.T) {
|
||||
Convey("Make manifest", t, func(c C) {
|
||||
dir := t.TempDir()
|
||||
@@ -510,3 +512,32 @@ func TestIsSignature(t *testing.T) {
|
||||
So(isSingature, ShouldBeFalse)
|
||||
})
|
||||
}
|
||||
|
||||
func TestDedupeGeneratorErrors(t *testing.T) {
|
||||
log := log.Logger{Logger: zerolog.New(os.Stdout)}
|
||||
|
||||
// Ideally this would be covered by the end-to-end test,
|
||||
// but the coverage for the error is unpredictable, prone to race conditions
|
||||
Convey("GetNextDigestWithBlobPaths errors", t, func(c C) {
|
||||
imgStore := &mocks.MockedImageStore{
|
||||
GetRepositoriesFn: func() ([]string, error) {
|
||||
return []string{"repo1", "repo2"}, nil
|
||||
},
|
||||
GetNextDigestWithBlobPathsFn: func(repos []string, lastDigests []godigest.Digest) (
|
||||
godigest.Digest, []string, error,
|
||||
) {
|
||||
return "sha256:123", []string{}, ErrTestError
|
||||
},
|
||||
}
|
||||
|
||||
generator := &common.DedupeTaskGenerator{
|
||||
ImgStore: imgStore,
|
||||
Dedupe: true,
|
||||
Log: log,
|
||||
}
|
||||
|
||||
task, err := generator.Next()
|
||||
So(err, ShouldNotBeNil)
|
||||
So(task, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user