Skip to content

Commit 04acfec

Browse files
increase coverage
Signed-off-by: Xiaoxuan Wang <[email protected]>
1 parent 895d186 commit 04acfec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

content/oci/oci_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,20 @@ func TestStore_GCErrorPath(t *testing.T) {
30283028
if err = s.GC(ctx); err == nil {
30293029
t.Fatal("expect an error when os.ReadDir()")
30303030
}
3031+
os.Remove(path.Join(algPath, "sha384"))
3032+
3033+
// test os.Remove() error
3034+
badDigest := digest.FromBytes([]byte("bad digest")).Encoded()
3035+
badPath := path.Join(algPath, "sha256", badDigest)
3036+
if err := os.Mkdir(badPath, 0444); err != nil {
3037+
t.Fatal(err)
3038+
}
3039+
if err := os.WriteFile(path.Join(badPath, "whatever"), []byte("extra content"), 0444); err != nil {
3040+
t.Fatal("error calling WriteFile(), error =", err)
3041+
}
3042+
if err = s.GC(ctx); err == nil {
3043+
t.Fatal("expect an error when os.Remove()")
3044+
}
30313045
}
30323046

30333047
func equalDescriptorSet(actual []ocispec.Descriptor, expected []ocispec.Descriptor) bool {

0 commit comments

Comments
 (0)