From fac7071bae86e416fff632385600753437f2c8aa Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 22 Feb 2024 14:38:26 +0100 Subject: [PATCH] refs #6414 fix(newWorker): back test --- db/dump/fixtures.before.sql | 3 +++ .../back/methods/worker/specs/new.spec.js | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 43293c9ea..7c6a2db6b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3068,3 +3068,6 @@ INSERT INTO `vn`.`cmr` (id,truckPlate,observations,senderInstruccions,paymentIns VALUES (1,'123456A','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',442,1,2,1,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (2,'123456N','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',69,3,4,2,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'), (3,'123456B','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet',567,5,6,69,'Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet','Lorem ipsum dolor sit amet'); + +UPDATE vn.department + SET workerFk = null; diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 1f74e9b95..d3e9cb9d0 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -139,9 +139,12 @@ describe('Worker new', () => { }); it('should create a new worker', async() => { - const newWorker = await models.Worker.new({args: defaultWorker, req}); - - await removeWorker(newWorker.id); + let newWorker; + try { + newWorker = await models.Worker.new({args: defaultWorker, req}); + } finally { + await removeWorker(newWorker.id); + } expect(newWorker.id).toBeDefined(); }); @@ -173,9 +176,12 @@ describe('Worker new', () => { }), req }; - const newWorker = await models.Worker.new(newWorkerData); - - await models.Worker.destroyById(newWorker.id); + let newWorker; + try { + newWorker = await models.Worker.new(newWorkerData); + } finally { + await models.Worker.destroyById(newWorker.id); + } expect(newWorker.id).toEqual(bruceWayneId); });