diff --git a/abstract/approximate-size-test.js b/abstract/approximate-size-test.js index 4c3ad1c6..8ae2221b 100644 --- a/abstract/approximate-size-test.js +++ b/abstract/approximate-size-test.js @@ -3,7 +3,7 @@ var leveldown var testCommon module.exports.setUp = function (_leveldown, test, _testCommon) { - test('setUp common', _testCommon.setUp) + test('setUp common for approximate size', _testCommon.setUp) test('setUp db', function (t) { leveldown = _leveldown testCommon = _testCommon @@ -68,7 +68,7 @@ module.exports.args = function (test) { }) test('test custom _serialize*', function (t) { - t.plan(3) + t.plan(4) var db = leveldown(testCommon.location()) db._serializeKey = function (data) { return data } db._approximateSize = function (start, end, callback) { @@ -79,6 +79,7 @@ module.exports.args = function (test) { db.open(function () { db.approximateSize({ foo: 'bar' }, { beep: 'boop' }, function (err) { t.error(err) + db.close(t.error.bind(t)) }) }) }) diff --git a/abstract/del-test.js b/abstract/del-test.js index d3600802..825cc19e 100644 --- a/abstract/del-test.js +++ b/abstract/del-test.js @@ -42,16 +42,17 @@ module.exports.args = function (test) { }) test('test custom _serialize*', function (t) { - t.plan(2) + t.plan(3) var db = leveldown(testCommon.location()) db._serializeKey = function (data) { return data } db._del = function (key, options, callback) { t.deepEqual(key, { foo: 'bar' }) - callback() + process.nextTick(callback) } db.open(function () { db.del({ foo: 'bar' }, function (err) { t.error(err) + db.close(t.error.bind(t)) }) }) }) @@ -63,7 +64,7 @@ module.exports.del = function (test) { t.error(err) db.del('foo', function (err) { t.error(err) - db.get('foo', function (err) { + db.get('foo', function (err, value) { t.ok(err, 'entry propertly deleted') t.ok(typeof value === 'undefined', 'value is undefined') t.ok(verifyNotFoundError(err), 'NotFound error') diff --git a/abstract/get-test.js b/abstract/get-test.js index a8473888..755651e4 100644 --- a/abstract/get-test.js +++ b/abstract/get-test.js @@ -43,16 +43,17 @@ module.exports.args = function (test) { }) test('test custom _serialize*', function (t) { - t.plan(2) + t.plan(3) var db = leveldown(testCommon.location()) db._serializeKey = function (data) { return data } db._get = function (key, options, callback) { t.deepEqual(key, { foo: 'bar' }) - callback() + process.nextTick(callback) } db.open(function () { db.get({ foo: 'bar' }, function (err) { t.error(err) + db.close(t.error.bind(t)) }) }) }) diff --git a/abstract/put-test.js b/abstract/put-test.js index b300c136..58d9fe75 100644 --- a/abstract/put-test.js +++ b/abstract/put-test.js @@ -56,7 +56,7 @@ module.exports.args = function (test) { db._put = function (key, value, opts, callback) { t.ok(key) t.ok(value) - callback() + process.nextTick(callback) } db.put({}, {}, function (err, val) { t.error(err) @@ -64,17 +64,18 @@ module.exports.args = function (test) { }) test('test custom _serialize*', function (t) { - t.plan(3) + t.plan(4) var db = leveldown(testCommon.location()) db._serializeKey = db._serializeValue = function (data) { return data } db._put = function (key, value, options, callback) { t.deepEqual(key, { foo: 'bar' }) t.deepEqual(value, { beep: 'boop' }) - callback() + process.nextTick(callback) } db.open(function () { db.put({ foo: 'bar' }, { beep: 'boop' }, function (err) { t.error(err) + db.close(t.error.bind(t)) }) }) }) diff --git a/testCommon.js b/testCommon.js index 8f5063c8..787eb9fa 100644 --- a/testCommon.js +++ b/testCommon.js @@ -13,7 +13,7 @@ var lastLocation = function () { } var cleanup = function (callback) { - if (process.browser) { return callback() } + if (process.browser) { return process.nextTick(callback) } fs.readdir(__dirname, function (err, list) { if (err) return callback(err) @@ -27,7 +27,8 @@ var cleanup = function (callback) { var ret = 0 list.forEach(function (f) { - rimraf(path.join(__dirname, f), function () { + rimraf(path.join(__dirname, f), function (err) { + if (err) return callback(err) if (++ret === list.length) { callback() } }) })