Skip to content

Commit

Permalink
assert no errors after cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Dec 23, 2017
1 parent 1828430 commit ab176e5
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions test/make.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
const test = require('tape')
, testCommon = require('abstract-leveldown/testCommon')
, cleanup = testCommon.cleanup
, location = testCommon.location
, leveldown = require('../')
const test = require('tape')
const testCommon = require('abstract-leveldown/testCommon')
const cleanup = testCommon.cleanup
const leveldown = require('../')

function makeTest (name, testFn) {
test(name, function (t) {
cleanup(function () {
var loc = location()
, db = leveldown(loc)
, done = function (close) {
if (close === false)
return cleanup(t.end.bind(t))
db.close(function (err) {
t.notOk(err, 'no error from close()')
cleanup(t.end.bind(t))
})
}
cleanup(function (err) {
t.error(err, 'no error after cleanup')
var location = testCommon.location()
var db = leveldown(location)
var done = function (close) {
if (close === false) {
cleanup(function (err) {
t.error(err, 'no error after cleanup')
t.end()
})
return
}
db.close(function (err) {
t.error(err, 'no error from close()')
cleanup(function (err) {
t.error(err, 'no error after cleanup')
t.end()
})
})
}
db.open(function (err) {
t.notOk(err, 'no error from open()')
db.batch(
[
{ type: 'put', key: 'one', value: '1' }
, { type: 'put', key: 'two', value: '2' }
, { type: 'put', key: 'three', value: '3' }
]
, function (err) {
t.notOk(err, 'no error from batch()')
testFn(db, t, done, loc)
}
)
t.error(err, 'no error from open()')
db.batch([
{ type: 'put', key: 'one', value: '1' },
{ type: 'put', key: 'two', value: '2' },
{ type: 'put', key: 'three', value: '3' }
], function (err) {
t.error(err, 'no error from batch()')
testFn(db, t, done, location)
})
})
})
})
Expand Down

0 comments on commit ab176e5

Please sign in to comment.