X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/40c9b26a39c773e806e0a1430774f1787820376f..bc816b50fc16182fef2f5d17ffd61578432e83c3:/services/keepstore/volume_generic_test.go diff --git a/services/keepstore/volume_generic_test.go b/services/keepstore/volume_generic_test.go index 74c5b2a7ef..7ef079f1f7 100644 --- a/services/keepstore/volume_generic_test.go +++ b/services/keepstore/volume_generic_test.go @@ -24,6 +24,7 @@ func DoGenericVolumeTests(t *testing.T, factory TestableVolumeFactory) { testGet(t, factory) testGetNoSuchBlock(t, factory) + testCompareNonexistent(t, factory) testCompareSameContent(t, factory, TestHash, TestBlock) testCompareSameContent(t, factory, EmptyHash, EmptyBlock) testCompareWithCollision(t, factory, TestHash, TestBlock, []byte("baddata")) @@ -95,6 +96,19 @@ func testGetNoSuchBlock(t *testing.T, factory TestableVolumeFactory) { } } +// Compare() should return os.ErrNotExist if the block does not exist. +// Otherwise, writing new data causes CompareAndTouch() to generate +// error logs even though everything is working fine. +func testCompareNonexistent(t *testing.T, factory TestableVolumeFactory) { + v := factory(t) + defer v.Teardown() + + err := v.Compare(TestHash, TestBlock) + if err != os.ErrNotExist { + t.Errorf("Got err %T %q, expected os.ErrNotExist", err, err) + } +} + // Put a test block and compare the locator with same content // Test should pass for both writable and read-only volumes func testCompareSameContent(t *testing.T, factory TestableVolumeFactory, testHash string, testData []byte) {