mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +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:
@@ -2261,9 +2261,29 @@ func TestRebuildDedupeIndex(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestRebuildDedupeMockStoreDriver(t *testing.T) {
|
||||
tskip.SkipS3(t)
|
||||
func TestNextRepositoryMockStoreDriver(t *testing.T) {
|
||||
testDir := t.TempDir()
|
||||
tdir := t.TempDir()
|
||||
|
||||
// some s3 implementations (eg, digitalocean spaces) will return pathnotfounderror for walk but not list
|
||||
// This code cannot be reliably covered by end to end tests
|
||||
Convey("Trigger PathNotFound error when Walk() is called in GetNextRepository()", t, func() {
|
||||
imgStore := createMockStorage(testDir, tdir, false, &StorageDriverMock{
|
||||
ListFn: func(ctx context.Context, path string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
},
|
||||
WalkFn: func(ctx context.Context, path string, walkFn driver.WalkFn) error {
|
||||
return driver.PathNotFoundError{}
|
||||
},
|
||||
})
|
||||
|
||||
nextRepository, err := imgStore.GetNextRepository("testRepo")
|
||||
So(err, ShouldBeNil)
|
||||
So(nextRepository, ShouldEqual, "")
|
||||
})
|
||||
}
|
||||
|
||||
func TestRebuildDedupeMockStoreDriver(t *testing.T) {
|
||||
uuid, err := guuid.NewV4()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
Reference in New Issue
Block a user