Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Commit 3e26e7a

Browse files
committed
fixup! Bump deferred-leveldown, encoding-down, memdown (tmp)
1 parent 5b3a514 commit 3e26e7a

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

test/deferred-open-test.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = function (test, testCommon) {
1010
test('deferred open(): put() and get() on new database', function (t) {
1111
// 1) open database without callback, opens in next tick
1212
const db = testCommon.factory()
13-
t.ok(typeof db === 'object' && db !== null)
1413

1514
parallel([
1615
// 2) insert 3 values with put(), these should be deferred until the database is actually open
@@ -34,15 +33,29 @@ module.exports = function (test, testCommon) {
3433
})
3534
})
3635

37-
// we should still be in a state of limbo down here, not opened or closed, but 'new'
38-
t.is(db.isOpen(), false)
39-
t.is(db.isClosed(), false)
36+
t.is(db.status, 'opening')
37+
})
38+
39+
test('deferred open(): put() and get() on reopened database', async function (t) {
40+
const db = testCommon.factory()
41+
42+
await db.close()
43+
t.is(db.status, 'closed')
44+
45+
db.open(() => {})
46+
t.is(db.status, 'opening')
47+
48+
await db.put('beep', 'boop')
49+
50+
t.is(db.status, 'open')
51+
t.is(await db.get('beep', { asBuffer: false }), 'boop')
52+
53+
await db.close()
4054
})
4155

4256
test('deferred open(): batch() on new database', function (t) {
4357
// 1) open database without callback, opens in next tick
4458
const db = testCommon.factory()
45-
t.ok(typeof db === 'object' && db !== null)
4659

4760
// 2) insert 3 values with batch(), these should be deferred until the database is actually open
4861
db.batch([
@@ -66,15 +79,12 @@ module.exports = function (test, testCommon) {
6679
})
6780
})
6881

69-
// we should still be in a state of limbo down here, not opened or closed, but 'new'
70-
t.is(db.isOpen(), false)
71-
t.is(db.isClosed(), false)
82+
t.is(db.status, 'opening')
7283
})
7384

7485
test('deferred open(): chained batch() on new database', function (t) {
7586
// 1) open database without callback, opens in next tick
7687
const db = testCommon.factory()
77-
t.ok(typeof db === 'object' && db !== null)
7888

7989
// 2) insert 3 values with batch(), these should be deferred until the database is actually open
8090
db.batch()
@@ -98,9 +108,7 @@ module.exports = function (test, testCommon) {
98108
})
99109
})
100110

101-
// we should still be in a state of limbo down here, not opened or closed, but 'new'
102-
t.is(db.isOpen(), false)
103-
t.is(db.isClosed(), false)
111+
t.is(db.status, 'opening')
104112
})
105113

106114
testCommon.streams && test('deferred open(): test deferred ReadStream', function (t) {

test/maybe-error-test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function (test, testCommon) {
1414
t.is(err.message, 'Database is not open')
1515
})
1616
t.is(sync, false, '.put cb called asynchronously')
17-
done()
17+
done() // TODO: called too soon, we still have 2 pending assertions
1818
})
1919
})
2020
})
@@ -72,4 +72,19 @@ module.exports = function (test, testCommon) {
7272
})
7373
})
7474
})
75+
76+
test('maybeError() should be called async: getMany()', function (t) {
77+
discardable(t, testCommon, function (db, done) {
78+
db.close(function () {
79+
t.is(db.status, 'closed', 'db is closed')
80+
let sync = false
81+
db.getMany(['key'], function (err) {
82+
sync = true
83+
t.is(err && err.message, 'Database is not open')
84+
done()
85+
})
86+
t.is(sync, false, '.getMany cb called asynchronously')
87+
})
88+
})
89+
})
7590
}

0 commit comments

Comments
 (0)