-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple test to make sure that a range compaction does infact redu…
…ce the size of the database
- Loading branch information
Gordon Hall
committed
Feb 1, 2017
1 parent
14ba38b
commit 017bcae
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const test = require('tape') | ||
, testCommon = require('abstract-leveldown/testCommon') | ||
, leveldown = require('../') | ||
|
||
var db | ||
|
||
test('setUp common', testCommon.setUp) | ||
|
||
test('setUp db', function (t) { | ||
db = leveldown(testCommon.location()) | ||
db.open(t.end.bind(t)) | ||
}) | ||
|
||
test('test compactRange() frees disk space after key deletion', function (t) { | ||
var key1 = '000000'; | ||
var key2 = '000001'; | ||
var val1 = Buffer(64).fill(1); | ||
var val2 = Buffer(64).fill(1); | ||
db.put(key1, val1, function() { | ||
db.put(key2, val2, function() { | ||
db.compactRange(key1, key2, function() { | ||
db.approximateSize('0', 'z', function(err, sizeAfterPuts) { | ||
db.del(key1, function() { | ||
db.del(key2, function() { | ||
db.compactRange(key1, key2, function() { | ||
db.approximateSize('0', 'z', function(err, sizeAfterCompact) { | ||
t.notEqual(sizeAfterCompact, sizeAfterPuts); | ||
t.end(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |