@defra-fish/sales-api-service 1.77.0-rc.12 → 1.77.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/sales-api-service",
|
|
3
|
-
"version": "1.77.0-rc.
|
|
3
|
+
"version": "1.77.0-rc.14",
|
|
4
4
|
"description": "Rod Licensing Sales API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@defra-fish/business-rules-lib": "1.77.0-rc.
|
|
39
|
-
"@defra-fish/connectors-lib": "1.77.0-rc.
|
|
40
|
-
"@defra-fish/dynamics-lib": "1.77.0-rc.
|
|
38
|
+
"@defra-fish/business-rules-lib": "1.77.0-rc.14",
|
|
39
|
+
"@defra-fish/connectors-lib": "1.77.0-rc.14",
|
|
40
|
+
"@defra-fish/dynamics-lib": "1.77.0-rc.14",
|
|
41
41
|
"@hapi/boom": "9.1.2",
|
|
42
42
|
"@hapi/hapi": "20.1.3",
|
|
43
43
|
"@hapi/inert": "6.0.3",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"moment-timezone": "0.5.34",
|
|
54
54
|
"uuid": "8.3.2"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c6cf6a1e30e4336d164902820c5fae0c08123821"
|
|
57
57
|
}
|
|
@@ -436,16 +436,22 @@ describe('transaction service', () => {
|
|
|
436
436
|
})
|
|
437
437
|
|
|
438
438
|
describe('when persisting throws an PermissionReferenceNumber_Key error', () => {
|
|
439
|
+
const permissionReferenceKeyError = () => {
|
|
440
|
+
const e = new Error()
|
|
441
|
+
e.error = {
|
|
442
|
+
message:
|
|
443
|
+
'Entity Key PermissionReferenceNumber_Key violated. A record with the same value for Permission Reference Number already exists. A duplicate record cannot be created. Select one or more unique values and try again.'
|
|
444
|
+
}
|
|
445
|
+
return e
|
|
446
|
+
}
|
|
447
|
+
|
|
439
448
|
it('does not throw an error', async () => {
|
|
440
449
|
const transactionFilename = 'test-file.xml'
|
|
441
450
|
const mockRecord = mockFinalisedTransactionRecord()
|
|
442
451
|
mockRecord.transactionFile = transactionFilename
|
|
443
452
|
retrieveStagedTransaction.mockResolvedValueOnce(mockRecord)
|
|
444
453
|
|
|
445
|
-
|
|
446
|
-
'Entity Key PermissionReferenceNumber_Key violated. A record with the same value for Permission Reference Number already exists. A duplicate record cannot be created. Select one or more unique values and try again.'
|
|
447
|
-
)
|
|
448
|
-
persist.mockRejectedValueOnce(error)
|
|
454
|
+
persist.mockRejectedValueOnce(permissionReferenceKeyError())
|
|
449
455
|
|
|
450
456
|
await expect(processQueue({ id: mockRecord.id })).resolves.not.toThrow()
|
|
451
457
|
})
|
|
@@ -456,10 +462,7 @@ describe('transaction service', () => {
|
|
|
456
462
|
mockRecord.transactionFile = transactionFilename
|
|
457
463
|
retrieveStagedTransaction.mockResolvedValueOnce(mockRecord)
|
|
458
464
|
|
|
459
|
-
|
|
460
|
-
'Entity Key PermissionReferenceNumber_Key violated. A record with the same value for Permission Reference Number already exists. A duplicate record cannot be created. Select one or more unique values and try again.'
|
|
461
|
-
)
|
|
462
|
-
persist.mockRejectedValueOnce(error)
|
|
465
|
+
persist.mockRejectedValueOnce(permissionReferenceKeyError())
|
|
463
466
|
|
|
464
467
|
await processQueue({ id: mockRecord.id })
|
|
465
468
|
|
|
@@ -472,10 +475,7 @@ describe('transaction service', () => {
|
|
|
472
475
|
mockRecord.transactionFile = transactionFilename
|
|
473
476
|
retrieveStagedTransaction.mockResolvedValueOnce(mockRecord)
|
|
474
477
|
|
|
475
|
-
|
|
476
|
-
'Entity Key PermissionReferenceNumber_Key violated. A record with the same value for Permission Reference Number already exists. A duplicate record cannot be created. Select one or more unique values and try again.'
|
|
477
|
-
)
|
|
478
|
-
persist.mockRejectedValueOnce(error)
|
|
478
|
+
persist.mockRejectedValueOnce(permissionReferenceKeyError())
|
|
479
479
|
|
|
480
480
|
await processQueue({ id: mockRecord.id })
|
|
481
481
|
|
|
@@ -493,10 +493,7 @@ describe('transaction service', () => {
|
|
|
493
493
|
mockRecord.transactionFile = transactionFilename
|
|
494
494
|
retrieveStagedTransaction.mockResolvedValueOnce(mockRecord)
|
|
495
495
|
|
|
496
|
-
|
|
497
|
-
'Entity Key PermissionReferenceNumber_Key violated. A record with the same value for Permission Reference Number already exists. A duplicate record cannot be created. Select one or more unique values and try again.'
|
|
498
|
-
)
|
|
499
|
-
persist.mockRejectedValueOnce(error)
|
|
496
|
+
persist.mockRejectedValueOnce(permissionReferenceKeyError())
|
|
500
497
|
|
|
501
498
|
await processQueue({ id: mockRecord.id })
|
|
502
499
|
|
|
@@ -180,7 +180,7 @@ const persistEntities = async (entities, transactionRecord, id) => {
|
|
|
180
180
|
try {
|
|
181
181
|
await persist(entities, transactionRecord.createdBy)
|
|
182
182
|
} catch (e) {
|
|
183
|
-
if (e
|
|
183
|
+
if (e?.error?.message.match(ALREADY_PERSISTED_ERROR)) {
|
|
184
184
|
debug('Permission for staging id %s has already been persisted', id)
|
|
185
185
|
} else {
|
|
186
186
|
throw e
|