refactoring
This commit is contained in:
@@ -23,6 +23,7 @@ func TestOnDisk(t *testing.T) {
|
||||
type test_data struct {
|
||||
data []byte
|
||||
fileId string
|
||||
size uint64
|
||||
}
|
||||
testData := make([]*test_data, writeCount)
|
||||
for i := 0; i < writeCount; i++ {
|
||||
@@ -31,12 +32,13 @@ func TestOnDisk(t *testing.T) {
|
||||
testData[i] = &test_data{
|
||||
data: buff,
|
||||
fileId: fmt.Sprintf("1,%daabbccdd", i+1),
|
||||
size: uint64(len(buff)),
|
||||
}
|
||||
cache.SetChunk(testData[i].fileId, testData[i].data)
|
||||
}
|
||||
|
||||
for i := 0; i < writeCount; i++ {
|
||||
data := cache.GetChunk(testData[i].fileId)
|
||||
data := cache.GetChunk(testData[i].fileId, testData[i].size)
|
||||
if bytes.Compare(data, testData[i].data) != 0 {
|
||||
t.Errorf("failed to write to and read from cache: %d", i)
|
||||
}
|
||||
@@ -47,7 +49,7 @@ func TestOnDisk(t *testing.T) {
|
||||
cache = NewChunkCache(0, tmpDir, totalDiskSizeMb, segmentCount)
|
||||
|
||||
for i := 0; i < writeCount; i++ {
|
||||
data := cache.GetChunk(testData[i].fileId)
|
||||
data := cache.GetChunk(testData[i].fileId, testData[i].size)
|
||||
if bytes.Compare(data, testData[i].data) != 0 {
|
||||
t.Errorf("failed to write to and read from cache: %d", i)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user