Work on refactoring global IP ban database calls
This commit is contained in:
parent
7fcf31dec6
commit
d0712d007e
5 changed files with 192 additions and 20 deletions
24
test/testutil/db.js
Normal file
24
test/testutil/db.js
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue