Skip to content

Commit

Permalink
Merge pull request #49 from Level/tests-for-empty-batch-values
Browse files Browse the repository at this point in the history
add tests for empty batch values
  • Loading branch information
nolanlawson committed May 30, 2016
2 parents eb030ea + 2b8dde6 commit 68c1bf4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test.js
Expand Up @@ -257,3 +257,35 @@ test('backing rbtree is buffer-aware', function(t){
})
})
})

test('empty value in batch', function (t) {
t.plan(6)

var db = new MemDOWN()
, noerr = function (err) {
t.error(err, 'opens correctly')
}
, noop = function () {}

db.open(noerr)

db.batch([{
type: 'put',
key: 'empty-string',
value: ''
}, {
type: 'put',
key: 'empty-buffer',
value: Buffer(0)
}], function (err) {
t.error(err, 'no error')
db.get('empty-string', function (err, val) {
t.error(err, 'no error')
t.same(val, Buffer(0), 'empty string')
})
db.get('empty-buffer', function (err, val) {
t.error(err, 'no error')
t.same(val, Buffer(0), 'empty buffer')
})
})
})

0 comments on commit 68c1bf4

Please sign in to comment.