2017-06-01 05:46:06 +00:00
|
|
|
const Promise = require('bluebird');
|
|
|
|
|
|
|
|
function MockDB(mockTx) {
|
|
|
|
this.mockTx = mockTx;
|
|
|
|
}
|
|
|
|
|
|
|
|
MockDB.prototype = {
|
|
|
|
runTransaction: function runTransaction(fn) {
|
|
|
|
return fn(this.mockTx);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function MockTx() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-29 05:58:40 +00:00
|
|
|
[
|
|
|
|
'del',
|
|
|
|
'distinct',
|
|
|
|
'insert',
|
|
|
|
'limit',
|
|
|
|
'orderBy',
|
|
|
|
'select',
|
|
|
|
'table',
|
|
|
|
'update',
|
|
|
|
'where',
|
|
|
|
].forEach(method => {
|
2017-06-01 05:46:06 +00:00
|
|
|
MockTx.prototype[method] = function () {
|
|
|
|
return Promise.reject(new Error(`No stub defined for method "${method}"`));
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
exports.MockDB = MockDB;
|
|
|
|
exports.MockTx = MockTx;
|