Skip to content

Commit

Permalink
add tests for empty batch values
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed May 30, 2016
1 parent eb030ea commit 2b8dde6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
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 2b8dde6

Please sign in to comment.