Closes db and removes files when a test ends via t.end().
Adds tests to make sure db is opened, closed and removed properly.
Supports multiple levelup backends via level-test, which also has built in support for MemDOWN. Default is leveldown.
Supports any test framework that has a test function and t.end and t.ok methods.
Extracted from the test code in level-ttl and made more generic.
Install
$ npm install ltest --save
Usage
var tape = require('tape')var test = require('ltest')(tape)test('put and stream', function (t, db, createReadStream) { db.put('foo', 'bar', function (err) { t.ok(!err, 'no put error') var count = 0 createReadStream() .on('data', function (data) { t.equal(data.key, 'foo') t.equal(data.value, 'bar') ++
TAP version 13# put and streamok 1 no error on open()ok 2 valid db objectok 3 no put errorok 4 should be equalok 5 should be equalok 6 should be equalok 7 no error on close()ok 8 db removed1..8# tests 8# pass 8# ok
Api
ltest([options, ]testFn)
Returns a test function of the form function (desc[, opts], cb) where desc is the test description, opts is an optional options object passed to underlying db and cb is a callback of the form function (t, db, createReadStream).
options object is optional and is passed on to levelup and to level-test. Use this to define things like 'keyEncoding' or other settings for levelup.
Set options.mem to true if you want an in memory db.
testFn is the test function that should be used. Use any framework you like as long as it's a function and supports t.end and t.ok methods.