Fixed few coverage flakes (#872)

* blobtesting: coverage for GetMetadata() returning ErrNotFound
* content: additional direct coverage for diskCommittedContentIndexCache
This commit is contained in:
Jarek Kowalski authored and GitHub committed 2021-03-07 00:03:20 -08:00
1 parent a6e96c31f8
commit b6e68fa28a
3 files changed
+16

No files matched your search

+10
View File
@@ -92,6 +92,16 @@ func AssertGetBlobNotFound(ctx context.Context, t testingT, s blob.Storage, blob
}
}
// AssertGetMetadataNotFound asserts that GetMetadata() for specified blobID returns ErrNotFound.
func AssertGetMetadataNotFound(ctx context.Context, t testingT, s blob.Storage, blobID blob.ID) {
t.Helper()
_, err := s.GetMetadata(ctx, blobID)
if !errors.Is(err, blob.ErrBlobNotFound) {
t.Errorf("GetMetadata(%v) returned %v, %v but expected ErrNotFound", blobID, err)
}
}
// AssertListResults asserts that the list results with given prefix return the specified list of names in order.
func AssertListResults(ctx context.Context, t testingT, s blob.Storage, prefix blob.ID, want ...blob.ID) {
t.Helper()
+1
View File
@@ -30,6 +30,7 @@ func VerifyStorage(ctx context.Context, t testingT, r blob.Storage) {
// First verify that blocks don't exist.
for _, b := range blocks {
AssertGetBlobNotFound(ctx, t, r, b.blk)
AssertGetMetadataNotFound(ctx, t, r, b.blk)
}
if err := r.DeleteBlob(ctx, "no-such-blob"); err != nil && !errors.Is(err, blob.ErrBlobNotFound) {
@@ -59,6 +59,11 @@ func testCache(t *testing.T, cache committedContentIndexCache, fakeTime *faketim
"c4": &Info{PackBlobID: "p2345", ID: "c4"},
})))
must(t, cache.addContentToCache(ctx, "ndx2", mustBuildPackIndex(t, packIndexBuilder{
"c3": &Info{PackBlobID: "p2345", ID: "c3"},
"c4": &Info{PackBlobID: "p2345", ID: "c4"},
})))
ndx1, err := cache.openIndex(ctx, "ndx1")
must(t, err)