8448-devToTest #3373

Merged
alexm merged 98 commits from 8448-devToTest into test 2025-01-21 10:00:50 +00:00
2 changed files with 9 additions and 10 deletions
Showing only changes of commit dbd8d816c0 - Show all commits

View File

@ -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;
}
};

View File

@ -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');