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"))
}
}
+// 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) {