Comparing version 1.4.1 to 1.5.0
@@ -23,2 +23,9 @@ // Load Modules | ||
if (this._settings.test) { | ||
this.disable = internals.disable; | ||
this.enable = internals.enable; | ||
} | ||
delete this._settings.test; // Always delete in case value is falsy | ||
this.tables = {}; | ||
@@ -177,1 +184,26 @@ }; | ||
}; | ||
internals.disable = function (table, method) { | ||
Hoek.assert(this.tables[table], 'Unknown table:', table); | ||
Hoek.assert(this.tables[table][method], 'Unknown method:', method); | ||
this.tables[table][method] = internals.disabled; | ||
}; | ||
internals.disabled = function () { | ||
var callback = arguments[arguments.length - 1]; | ||
return callback(new Error('Simulated database error')); | ||
}; | ||
internals.enable = function (table, method) { | ||
Hoek.assert(this.tables[table], 'Unknown table:', table); | ||
Hoek.assert(this.tables[table][method], 'Unknown method:', method); | ||
this.tables[table][method] = Table.prototype[method]; | ||
}; |
{ | ||
"name": "penseur", | ||
"description": "Lightweight RethinkDB wrapper", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)", | ||
@@ -12,3 +12,3 @@ "repository": "git://github.com/hueniverse/penseur", | ||
"engines": { | ||
"node": ">=0.10.40" | ||
"node": "4.x.x" | ||
}, | ||
@@ -15,0 +15,0 @@ "dependencies": { |
@@ -229,2 +229,39 @@ // Load modules | ||
}); | ||
describe('disable()', function () { | ||
it('simulates an error', function (done) { | ||
var db = new Penseur.Db('penseurtest', { host: 'localhost', port: 28015, test: true }); | ||
db.establish(['test'], function (err) { | ||
expect(err).to.not.exist(); | ||
db.test.insert({ id: 1, value: 'x' }, function (err, result) { | ||
expect(err).to.not.exist(); | ||
db.test.get(1, function (err, item1) { | ||
expect(err).to.not.exist(); | ||
expect(item1.value).to.equal('x'); | ||
db.disable('test', 'get'); | ||
db.test.get(1, function (err, item2) { | ||
expect(err).to.exist(); | ||
db.enable('test', 'get'); | ||
db.test.get(1, function (err, item3) { | ||
expect(err).to.not.exist(); | ||
expect(item3.value).to.equal('x'); | ||
db.close(done); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50981
1150