Work on refactoring global IP ban database calls

This commit is contained in:
Calvin Montgomery 2017-05-31 22:46:06 -07:00
parent 7fcf31dec6
commit d0712d007e
5 changed files with 192 additions and 20 deletions

24
test/testutil/db.js Normal file
View file

@ -0,0 +1,24 @@
const Promise = require('bluebird');
function MockDB(mockTx) {
this.mockTx = mockTx;
}
MockDB.prototype = {
runTransaction: function runTransaction(fn) {
return fn(this.mockTx);
}
};
function MockTx() {
}
['insert', 'update', 'select', 'del', 'where', 'table'].forEach(method => {
MockTx.prototype[method] = function () {
return Promise.reject(new Error(`No stub defined for method "${method}"`));
};
});
exports.MockDB = MockDB;
exports.MockTx = MockTx;