projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
8555: Fix EmptyTrash so it can clean up old races.
[arvados.git]
/
services
/
keepstore
/
handlers_with_generic_volume_test.go
diff --git
a/services/keepstore/handlers_with_generic_volume_test.go
b/services/keepstore/handlers_with_generic_volume_test.go
index c5349d399c32ebc5692d0a39d4cc8c9c3ad83e1a..dda7edcec3509e683465a93d5eb775bf18f16d19 100644
(file)
--- a/
services/keepstore/handlers_with_generic_volume_test.go
+++ b/
services/keepstore/handlers_with_generic_volume_test.go
@@
-45,12
+45,13
@@
func testGetBlock(t TB, factory TestableVolumeManagerFactory, testHash string, t
testableVolumes[1].PutRaw(testHash, testBlock)
// Get should pass
testableVolumes[1].PutRaw(testHash, testBlock)
// Get should pass
- buf, err := GetBlock(testHash)
+ buf := make([]byte, len(testBlock))
+ n, err := GetBlock(testHash, buf, nil)
if err != nil {
t.Fatalf("Error while getting block %s", err)
}
if err != nil {
t.Fatalf("Error while getting block %s", err)
}
- if bytes.Compare(buf, testBlock) != 0 {
- t.Errorf("Put succeeded but Get returned %+v, expected %+v", buf, testBlock)
+ if bytes.Compare(buf
[:n]
, testBlock) != 0 {
+ t.Errorf("Put succeeded but Get returned %+v, expected %+v", buf
[:n]
, testBlock)
}
}
}
}
@@
-64,9
+65,10
@@
func testPutRawBadDataGetBlock(t TB, factory TestableVolumeManagerFactory,
testableVolumes[1].PutRaw(testHash, badData)
// Get should fail
testableVolumes[1].PutRaw(testHash, badData)
// Get should fail
- _, err := GetBlock(testHash)
+ buf := make([]byte, BlockSize)
+ size, err := GetBlock(testHash, buf, nil)
if err == nil {
if err == nil {
- t.Fatalf("
Expected error while getting corrupt block %v"
, testHash)
+ t.Fatalf("
Got %+q, expected error while getting corrupt block %v", buf[:size]
, testHash)
}
}
}
}
@@
-85,11
+87,12
@@
func testPutBlock(t TB, factory TestableVolumeManagerFactory, testHash string, t
}
// Check that PutBlock stored the data as expected
}
// Check that PutBlock stored the data as expected
- buf, err := GetBlock(testHash)
+ buf := make([]byte, BlockSize)
+ size, err := GetBlock(testHash, buf, nil)
if err != nil {
t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
if err != nil {
t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
- } else if bytes.Compare(buf, testBlock) != 0 {
- t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf)
+ } else if bytes.Compare(buf
[:size]
, testBlock) != 0 {
+ t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf
[:size]
)
}
}
}
}
@@
-109,10
+112,11
@@
func testPutBlockCorrupt(t TB, factory TestableVolumeManagerFactory,
// Put succeeded and overwrote the badData in one volume,
// and Get should return the testBlock now, ignoring the bad data.
// Put succeeded and overwrote the badData in one volume,
// and Get should return the testBlock now, ignoring the bad data.
- buf, err := GetBlock(testHash)
+ buf := make([]byte, BlockSize)
+ size, err := GetBlock(testHash, buf, nil)
if err != nil {
t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
if err != nil {
t.Fatalf("Error during GetBlock for %q: %s", testHash, err)
- } else if bytes.Compare(buf, testBlock) != 0 {
- t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf)
+ } else if bytes.Compare(buf
[:size]
, testBlock) != 0 {
+ t.Errorf("Get response incorrect. Expected %q; found %q", testBlock, buf
[:size]
)
}
}
}
}