Compare commits

...

11 Commits

Author SHA1 Message Date
Alex Moreno c46f379c8e Merge branch 'dev' into 5160-backTest_jenkins2
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-31 11:12:13 +00:00
Alex Moreno cfcfdc9d12 try
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-29 07:20:06 +02:00
Alex Moreno dd16633b53 try
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-19 08:34:51 +02:00
Alex Moreno 08ac3ab0a1 try
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-18 15:19:17 +02:00
Alex Moreno 4bf4a263c4 try fancy-logs
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-18 15:07:12 +02:00
Alex Moreno 20c308d228 try
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-18 15:02:08 +02:00
Alex Moreno e4496cf062 try console.logs
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-18 14:56:21 +02:00
Alex Moreno 964b92e497 Merge branch 'dev' into 5160-backTest_jenkins2
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-18 12:44:45 +00:00
Alex Moreno 84e0427d93 Merge branch 'dev' into 5160-backTest_jenkins2
gitea/salix/pipeline/head There was a failure building this commit Details
2023-05-17 12:41:34 +00:00
Alex Moreno a3488d44ae refs #5160 try show Application.status
gitea/salix/pipeline/head This commit looks good Details
2023-05-17 08:45:47 +02:00
Alex Moreno 6ab6dbe51a refs #5160 try console.log
gitea/salix/pipeline/head This commit looks good Details
2023-05-17 08:35:00 +02:00
3 changed files with 47 additions and 9 deletions

View File

@ -1,5 +1,7 @@
const Docker = require('../db/docker.js');
let dataSources = require('../loopback/server/datasources.json');
const log = require('fancy-log');
const models = require('vn-loopback/server/server').models;
process.on('warning', warning => {
console.log(warning.name);
@ -35,7 +37,25 @@ async function test() {
err => err ? reject(err) : resolve());
});
// FIXME: Workaround to wait for loopback to be ready
await app.models.Application.status();
log('Waiting for backend is ready...');
log('Application ready', await app.models.Application.status());
const params = {
zoneFk: 1,
geoFk: 20,
isIncluded: false
};
log('Start upsert WITHOUT transaction');
await models.ZoneIncluded.upsert(params);
log('Finish first upsert');
log('Start transaction');
const tx = await models.Zone.beginTransaction({});
log('Start upsert WITH transaction');
await models.ZoneIncluded.upsert(params, {transaction: tx});
log('Finish second upsert');
await tx.rollback();
log('Finish rollback');
const Jasmine = require('jasmine');
const jasmine = new Jasmine();
@ -55,7 +75,7 @@ async function test() {
const JunitReporter = require('jasmine-reporters');
jasmine.addReporter(new JunitReporter.JUnitXmlReporter());
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
jasmine.exitOnCompletion = true;
}

View File

@ -1,5 +1,6 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const log = require('fancy-log');
describe('zone toggleIsIncluded()', () => {
beforeAll(async() => {
@ -16,17 +17,22 @@ describe('zone toggleIsIncluded()', () => {
});
});
it('should return the created location with isIncluded true', async() => {
fit('should return the created location with isIncluded true', async() => {
log('transaction start');
const tx = await models.Zone.beginTransaction({});
log('transaction ready');
try {
const options = {transaction: tx};
log('Zone.toggleIsIncluded start');
let result = await models.Zone.toggleIsIncluded(1, 20, true, options);
log('Zone.toggleIsIncluded finish');
expect(result.isIncluded).toBeTrue();
log('rollback start');
await tx.rollback();
log('rollback finish');
} catch (e) {
await tx.rollback();
throw e;

View File

@ -1,3 +1,5 @@
const log = require('fancy-log');
module.exports = Self => {
Self.remoteMethod('toggleIsIncluded', {
description: 'Toggle include to delivery',
@ -28,20 +30,30 @@ module.exports = Self => {
});
Self.toggleIsIncluded = async(id, geoId, isIncluded, options) => {
log('Zone.toggleIsIncluded entry');
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
if (typeof options == 'object') {
log(`Don't use new transacction`);
Object.assign(myOptions, options);
}
if (isIncluded === undefined)
return models.ZoneIncluded.destroyAll({zoneFk: id, geoFk: geoId}, myOptions);
else {
return models.ZoneIncluded.upsert({
let data;
if (isIncluded === undefined) {
log('Zone.toggleIsIncluded destroyAll start');
data = await models.ZoneIncluded.destroyAll({zoneFk: id, geoFk: geoId}, myOptions);
} else {
log('Zone.toggleIsIncluded upsert start');
data = await models.ZoneIncluded.upsert({
zoneFk: id,
geoFk: geoId,
isIncluded: isIncluded
}, myOptions);
}
log('Zone.toggleIsIncluded return');
return data;
};
};