Skip to content

Commit

Permalink
add simple test to make sure that a range compaction does infact redu…
Browse files Browse the repository at this point in the history
…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.
37 changes: 37 additions & 0 deletions test/compact-range-test.js
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();
});
});
});
});
});
});
});
});
});

0 comments on commit 017bcae

Please sign in to comment.