Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that each factory returns a unique db #282

Merged
merged 2 commits into from
Jul 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/factory-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var concat = require('level-concat-iterator')

module.exports = function (test, testCommon) {
test('setUp common', testCommon.setUp)

test('testCommon.factory() returns a unique database', function (t) {
var db1 = testCommon.factory()
var db2 = testCommon.factory()

function close () {
db1.close(function (err) {
t.error(err, 'no error while closing db1')
db2.close(function (err) {
t.error(err, 'no error while closing db2')
t.end()
})
})
}

db1.open(function (err) {
t.error(err, 'no error while opening db1')
db2.open(function (err) {
t.error(err, 'no error while opening db2')
db1.put('key', 'value', function (err) {
t.error(err, 'put key in db1')
concat(db2.iterator(), function (err, entries) {
t.error(err, 'got items from db2')
t.same(entries, [], 'db2 should be empty')
close()
})
})
})
})
})

test('tearDown', testCommon.tearDown)
}
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = function (options) {
var testCommon = common(options)
var test = testCommon.test

require('./factory-test')(test, testCommon)

require('./leveldown-test').args(test, testCommon)
require('./open-test').all(test, testCommon)
require('./close-test').all(test, testCommon)
Expand Down