Merge pull request #1033 from strongloop/fix/kvao-expire-error-status-code
KeyValueAccessObject: return 404 when expiring unknown key
This commit is contained in:
commit
8e81185375
|
@ -109,7 +109,9 @@ function(modelName, key, ttl, options, callback) {
|
|||
|
||||
if (!(key in store)) {
|
||||
return process.nextTick(function() {
|
||||
callback(new Error('Cannot expire unknown key ' + key));
|
||||
var err = new Error('Cannot expire unknown key ' + key);
|
||||
err.statusCode = 404;
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
it('returns error when key does not exist', function() {
|
||||
return CacheItem.expire('key-does-not-exist', 1).then(
|
||||
function() { throw new Error('expire() should have failed'); },
|
||||
function(err) { err.message.should.match(/key-does-not-exist/); });
|
||||
function(err) {
|
||||
err.message.should.match(/key-does-not-exist/);
|
||||
err.should.have.property('statusCode', 404);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue