Skip to content

Commit

Permalink
increase coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 committed Jan 9, 2024
1 parent 97265c9 commit 2b528b9
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions content/oci/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3008,15 +3008,15 @@ func TestStore_GCErrorPath(t *testing.T) {
t.Fatal(err)
}

// appendBlob(ocispec.MediaTypeImageLayer, []byte("valid blob 2")) // Blob 1
appendBlob(ocispec.MediaTypeImageLayer, []byte("valid blob 2")) // Blob 1

// // push the valid blob
// err = s.Push(ctx, descs[1], bytes.NewReader(blobs[1]))
// if err != nil {
// t.Error("failed to push test content to src")
// }
// push the valid blob
err = s.Push(ctx, descs[1], bytes.NewReader(blobs[1]))
if err != nil {
t.Error("failed to push test content to src")
}

// // test os.ReadDir() errors
// test os.ReadDir() errors
// s.root = "random dir"
// if err = s.GC(ctx); err == nil {
// t.Fatal("expect an error when os.ReadDir()")
Expand All @@ -3032,18 +3032,18 @@ func TestStore_GCErrorPath(t *testing.T) {
// t.Fatal(err)
// }

// // test os.Remove() error
// badDigest := digest.FromBytes([]byte("bad digest")).Encoded()
// badPath := path.Join(algPath, "sha256", badDigest)
// if err := os.Mkdir(badPath, 0777); err != nil {
// t.Fatal(err)
// }
// if err := os.WriteFile(path.Join(badPath, "whatever"), []byte("extra content"), 0444); err != nil {
// t.Fatal("error calling WriteFile(), error =", err)
// }
// if err = s.GC(ctx); err == nil {
// t.Fatal("expect an error when os.Remove()")
// }
// test os.Remove() error
badDigest := digest.FromBytes([]byte("bad digest")).Encoded()
badPath := path.Join(algPath, "sha256", badDigest)
if err := os.Mkdir(badPath, 0777); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path.Join(badPath, "whatever"), []byte("extra content"), 0444); err != nil {
t.Fatal("error calling WriteFile(), error =", err)
}
if err = s.GC(ctx); err == nil {
t.Fatal("expect an error when os.Remove()")
}
}

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

0 comments on commit 2b528b9

Please sign in to comment.