8448-devToTest #3373
|
@ -16,12 +16,14 @@ module.exports = Self => {
|
|||
Self.exchangeRateUpdate = async(options = {}) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
Object.assign(myOptions, options);
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
let createdTx = false;
|
||||
if (!myOptions.transaction) {
|
||||
myOptions.transaction = await Self.beginTransaction({});
|
||||
createdTx = true;
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -97,12 +99,9 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
|
||||
if (createdTx)
|
||||
await myOptions.transaction.commit();
|
||||
if (tx) await tx.commit();
|
||||
} catch (error) {
|
||||
if (createdTx)
|
||||
await myOptions.transaction.rollback();
|
||||
|
||||
if (tx) await tx.rollback();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -142,7 +142,7 @@ describe('exchangeRateUpdate functionality', function() {
|
|||
expect(afterCount - beforeCount).toBe(4);
|
||||
});
|
||||
|
||||
fit('should create entries for day1 and day2 from the feed, and not backfill day3', async function() {
|
||||
it('should create entries for day1 and day2 from the feed, and not backfill day3', async function() {
|
||||
const lastRate = await models.ReferenceRate.findOne({order: 'dated DESC'}, options);
|
||||
if (!lastRate) return fail('No existing ReferenceRate data in DB');
|
||||
|
||||
|
|
Loading…
Reference in New Issue