allow storing null in redis

This commit is contained in:
Sami Samhuri 2011-05-22 12:32:03 -07:00
parent faa8ab9486
commit 6acc1fc533
2 changed files with 17 additions and 1 deletions

View file

@ -151,7 +151,7 @@ Redis.prototype.set = function (key, value, callback) {
var fullKey = nconf.key(self.namespace, key);
if (!Array.isArray(value) && typeof value === 'object') {
if (!Array.isArray(value) && value !== null && typeof value === 'object') {
//
// If the value is an `Object` (and not an `Array`) then
// nest into the value and set the child keys appropriately.

View file

@ -37,6 +37,14 @@ vows.describe('nconf/stores/redis').addBatch({
"should respond without an error": function (err, ok) {
assert.isNull(err);
}
},
"with null": {
topic: function (store) {
store.set('falsy:object', null, this.callback);
},
"should respond without an error": function(err, ok) {
assert.isNull(err);
}
}
}
}
@ -75,6 +83,14 @@ vows.describe('nconf/stores/redis').addBatch({
"should respond with the correct value": function (err, value) {
assert.deepEqual(value, data.obj.auth);
}
},
"with null": {
topic: function(store) {
store.get('falsy:object', this.callback);
},
"should respond with the correct value": function(err, value) {
assert.equal(value, null);
}
}
}
}