Skip to content

Commit

Permalink
Allow serialization functions to return buffers
Browse files Browse the repository at this point in the history
This just loosens up the tests to allow _serlialize* functions to force buffers
for string keys or values. The underlying store impl might prefer (or require) buffers.
  • Loading branch information
deanlandolt committed Mar 9, 2016
1 parent f485430 commit b3ed5ab
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions abstract/approximate-size-test.js
Expand Up @@ -71,8 +71,8 @@ module.exports.args = function (test) {
t.plan(3)
var db = leveldown(testCommon.location())
db._approximateSize = function (start, end, callback) {
t.equal(start, '[object Object]')
t.equal(end, '[object Object]')
t.equal(Buffer.isBuffer(start) ? String(start) : start, '[object Object]')
t.equal(Buffer.isBuffer(end) ? String(end) : end, '[object Object]')
callback()
}
db.approximateSize({}, {}, function (err, val) {
Expand Down
4 changes: 4 additions & 0 deletions abstract/chained-batch-test.js
Expand Up @@ -181,6 +181,10 @@ module.exports.args = function (test) {
batch
.put({ foo: 'bar' }, { beep: 'boop' })
.del({ bar: 'baz' })
ops.forEach(function (op) {
if (Buffer.isBuffer(op.key)) op.key = String(op.key)
if (Buffer.isBuffer(op.value)) op.value = String(op.value)
})
t.deepEqual(ops, [
{ type: 'put', key: '[object Object]', value: '[object Object]' }
, { type: 'del', key: '[object Object]' }
Expand Down
2 changes: 1 addition & 1 deletion abstract/del-test.js
Expand Up @@ -46,7 +46,7 @@ module.exports.args = function (test) {
t.plan(2)
var db = leveldown(testCommon.location())
db._del = function (key, opts, callback) {
t.equal(key, '[object Object]')
t.equal(Buffer.isBuffer(key) ? String(key) : key, '[object Object]')
callback()
}
db.del({}, function (err, val) {
Expand Down
2 changes: 1 addition & 1 deletion abstract/get-test.js
Expand Up @@ -46,7 +46,7 @@ module.exports.args = function (test) {
t.plan(2)
var db = leveldown(testCommon.location())
db._get = function (key, opts, callback) {
t.equal(key, '[object Object]')
t.equal(Buffer.isBuffer(key) ? String(key) : key, '[object Object]')
callback()
}
db.get({}, function (err, val) {
Expand Down
4 changes: 2 additions & 2 deletions abstract/put-test.js
Expand Up @@ -55,8 +55,8 @@ module.exports.args = function (test) {
t.plan(3)
var db = leveldown(testCommon.location())
db._put = function (key, value, opts, callback) {
t.equal(key, '[object Object]')
t.equal(value, '[object Object]')
t.equal(Buffer.isBuffer(key) ? String(key) : key, '[object Object]')
t.equal(Buffer.isBuffer(value) ? String(value) : value, '[object Object]')
callback()
}
db.put({}, {}, function (err, val) {
Expand Down

0 comments on commit b3ed5ab

Please sign in to comment.