refs #6184 saveCmr #1788

Merged
guillermo merged 58 commits from 6184-saveCmr into dev 2024-02-13 06:47:06 +00:00
4 changed files with 8 additions and 14 deletions
Showing only changes of commit 2cab007f57 - Show all commits

View File

@ -96,6 +96,7 @@ async function test() {
// runner.loadConfigFile('back/jasmine.json'); // runner.loadConfigFile('back/jasmine.json');
runner.loadConfig(config); runner.loadConfig(config);
process.env.SPEC_IS_RUNNING = true;
await runner.execute(); await runner.execute();
} }

View File

@ -1,10 +1,6 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
guillermo marked this conversation as resolved
Review

No acabo de ver el enfoque de este test. Al final lo que estas haciendo es mockear la funcion para que devuelva lo que quieres. Realmente no esta testeando nada.

Veria mejor enfoque mockear generateNodeStream que es lo que supongo que debes evitar hacer.

Recuerda usar rollback

No acabo de ver el enfoque de este test. Al final lo que estas haciendo es mockear la funcion para que devuelva lo que quieres. Realmente no esta testeando nada. Veria mejor enfoque mockear generateNodeStream que es lo que supongo que debes evitar hacer. _Recuerda usar rollback_
Review

Falta esta parte

Falta esta parte
describe('route downloadCmrsZip()', () => { describe('route downloadCmrsZip()', () => {
beforeEach(() => {
spyOn(models.Route, 'downloadCmrsZip').and.returnValue(true);
});
it('should create a zip file with the given cmr ids', async() => { it('should create a zip file with the given cmr ids', async() => {
const tx = await models.Route.beginTransaction({}); const tx = await models.Route.beginTransaction({});
const ctx = { const ctx = {
@ -19,7 +15,7 @@ describe('route downloadCmrsZip()', () => {
try { try {
const stream = await models.Route.downloadCmrsZip(ctx, cmrs); const stream = await models.Route.downloadCmrsZip(ctx, cmrs);
expect(stream).toBeTrue(); expect(stream[0]).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();

View File

@ -1,10 +1,6 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
describe('ticket saveCmr()', () => { describe('ticket saveCmr()', () => {
beforeEach(() => {
spyOn(models.Ticket, 'saveCmr').and.returnValue(true);
});
it(`should throw error if the cmr can't save`, async() => { it(`should throw error if the cmr can't save`, async() => {
const tx = await models.Ticket.beginTransaction({}); const tx = await models.Ticket.beginTransaction({});
const ctx = { const ctx = {
@ -18,11 +14,11 @@ describe('ticket saveCmr()', () => {
}; };
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
const ticket = [1]; const ticket = [2];
await models.Ticket.saveCmr(ctx, ticket); await models.Ticket.saveCmr(ctx, ticket, options);
const hasDmsCmr = await models.TicketDms.findOne({ const hasDmsCmr = await models.TicketDms.findOne({
where: {ticketFk: ticket[1]}, where: {ticketFk: ticket[0]},
include: [{ include: [{
relation: 'dms', relation: 'dms',
fields: ['id'], fields: ['id'],
@ -35,7 +31,7 @@ describe('ticket saveCmr()', () => {
}] }]
}, options); }, options);
expect(hasDmsCmr?.dms()?.dmsType()).toEqual(1); expect(hasDmsCmr?.dms()?.id).toBeGreaterThanOrEqual(1);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
await tx.rollback(); await tx.rollback();

View File

@ -35,7 +35,8 @@ module.exports = {
logger.error(`[Print] => ${err.message}`); logger.error(`[Print] => ${err.message}`);
}); });
cluster.on('queue', () => logger.info('Printing task initialized by pool')); cluster.on('queue', () =>
process.env.SPEC_IS_RUNNING === 'false' && logger.info('Printing task initialized by pool'));
}); });
} }
}; };