diff --git a/objstore_test.go b/objstore_test.go index f7bd51ac..67c39802 100644 --- a/objstore_test.go +++ b/objstore_test.go @@ -28,7 +28,7 @@ func TestMetricBucket_Close(t *testing.T) { testutil.Equals(t, 7, promtest.CollectAndCount(bkt.metrics.opsFailures)) testutil.Equals(t, 7, promtest.CollectAndCount(bkt.metrics.opsDuration)) - AcceptanceTest(t, bkt.WithExpectedErrs(bkt.IsObjNotFoundErr)) + AcceptanceTest(t, bkt.WithExpectedErrs(bkt.IsObjNotFoundErr), true) testutil.Equals(t, float64(9), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpIter))) testutil.Equals(t, float64(2), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpAttributes))) testutil.Equals(t, float64(3), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpGet))) @@ -51,7 +51,7 @@ func TestMetricBucket_Close(t *testing.T) { // Clear bucket, but don't clear metrics to ensure we use same. bkt.bkt = NewInMemBucket() - AcceptanceTest(t, bkt) + AcceptanceTestWithoutNotFoundErr(t, bkt) testutil.Equals(t, float64(18), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpIter))) testutil.Equals(t, float64(4), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpAttributes))) testutil.Equals(t, float64(6), promtest.ToFloat64(bkt.metrics.ops.WithLabelValues(OpGet))) diff --git a/objtesting/acceptance_e2e_test.go b/objtesting/acceptance_e2e_test.go index e162cee5..611dd382 100644 --- a/objtesting/acceptance_e2e_test.go +++ b/objtesting/acceptance_e2e_test.go @@ -14,5 +14,5 @@ import ( // NOTE: This test assumes strong consistency, but in the same way it does not guarantee that if it passes, the // used object store is strongly consistent. func TestObjStore_AcceptanceTest_e2e(t *testing.T) { - ForeachStore(t, objstore.AcceptanceTest) + ForeachStore(t, objstore.AcceptanceTestWithoutNotFoundErr) } diff --git a/prefixed_bucket_test.go b/prefixed_bucket_test.go index f93c8580..b3109f6e 100644 --- a/prefixed_bucket_test.go +++ b/prefixed_bucket_test.go @@ -23,7 +23,7 @@ func TestPrefixedBucket_Acceptance(t *testing.T) { "someprefix"} for _, prefix := range prefixes { - AcceptanceTest(t, NewPrefixedBucket(NewInMemBucket(), prefix)) + AcceptanceTestWithoutNotFoundErr(t, NewPrefixedBucket(NewInMemBucket(), prefix)) UsesPrefixTest(t, NewInMemBucket(), prefix) } } diff --git a/testing.go b/testing.go index b8e3744c..30b9d5f4 100644 --- a/testing.go +++ b/testing.go @@ -80,7 +80,11 @@ func (b noopInstrumentedBucket) ReaderWithExpectedErrs(IsOpFailureExpectedFunc) return b } -func AcceptanceTest(t *testing.T, bkt Bucket) { +func AcceptanceTestWithoutNotFoundErr(t *testing.T, bkt Bucket) { + AcceptanceTest(t, bkt, false) +} + +func AcceptanceTest(t *testing.T, bkt Bucket, expectedNotFoundErr bool) { ctx := context.Background() _, err := bkt.Get(ctx, "") @@ -88,16 +92,20 @@ func AcceptanceTest(t *testing.T, bkt Bucket) { testutil.Assert(t, !bkt.IsObjNotFoundErr(err), "expected user error got not found %s", err) _, err = bkt.Get(ctx, "id1/obj_1.some") - testutil.NotOk(t, err) - testutil.Assert(t, bkt.IsObjNotFoundErr(err), "expected not found error got %s", err) + if !expectedNotFoundErr { + testutil.NotOk(t, err) + testutil.Assert(t, bkt.IsObjNotFoundErr(err), "expected not found error got %s", err) + } ok, err := bkt.Exists(ctx, "id1/obj_1.some") testutil.Ok(t, err) testutil.Assert(t, !ok, "expected not exits") _, err = bkt.Attributes(ctx, "id1/obj_1.some") - testutil.NotOk(t, err) - testutil.Assert(t, bkt.IsObjNotFoundErr(err), "expected not found error but got %s", err) + if !expectedNotFoundErr { + testutil.NotOk(t, err) + testutil.Assert(t, bkt.IsObjNotFoundErr(err), "expected not found error got %s", err) + } // Upload first object. testutil.Ok(t, bkt.Upload(ctx, "id1/obj_1.some", strings.NewReader("@test-data@")))