@defra-fish/sqs-receiver-service 1.65.0-rc.4 → 1.65.0-rc.6

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/sqs-receiver-service",
3
- "version": "1.65.0-rc.4",
3
+ "version": "1.65.0-rc.6",
4
4
  "description": "SQS Receiver service",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,7 +35,7 @@
35
35
  "test": "echo \"Error: run tests from root\" && exit 1"
36
36
  },
37
37
  "dependencies": {
38
- "@defra-fish/connectors-lib": "1.65.0-rc.4",
38
+ "@defra-fish/connectors-lib": "1.65.0-rc.6",
39
39
  "debug": "4.3.1",
40
40
  "joi": "17.3.0",
41
41
  "node-fetch": "2.6.1",
@@ -44,5 +44,5 @@
44
44
  "devDependencies": {
45
45
  "pm2": "4.5.6"
46
46
  },
47
- "gitHead": "47a57b982b698bea3a6e03473d7bbaa4ec733180"
47
+ "gitHead": "b6f6c0f7013edf124c9509603b05fe626170d68a"
48
48
  }
@@ -8,8 +8,8 @@ const getSampleDeleteMessageBatchResponse = (successfulIds, failedIds = []) => (
8
8
  ResponseMetadata: {
9
9
  RequestId: '00000000-0000-0000-0000-000000000000'
10
10
  },
11
- Successful: successfulIds.map(Id => ({ Id })),
12
- Failed: failedIds.map(Id => ({ Id }))
11
+ ...(successfulIds.length ? { Successful: successfulIds.map(Id => ({ Id })) } : {}),
12
+ ...(failedIds.length ? { Failed: failedIds.map(Id => ({ Id })) } : {})
13
13
  })
14
14
 
15
15
  jest.mock('@defra-fish/connectors-lib', () => ({
@@ -49,6 +49,32 @@ test('Delete messages successfully', async () => {
49
49
  expect(results).toBeUndefined()
50
50
  })
51
51
 
52
+ test("Delete messages successfully doesn't generate an error", async () => {
53
+ const consoleErrorSpy = jest.spyOn(console, 'error')
54
+ sqs.deleteMessageBatch.mockResolvedValueOnce(
55
+ getSampleDeleteMessageBatchResponse(['58f6f3c9-97f8-405a-a3a7-5ac467277521', '58f6f3c9-97f8-405a-a3a7-5ac467277522'])
56
+ )
57
+ await deleteMessages('http://0.0.0.0:0000/queue', [
58
+ {
59
+ id: '58f6f3c9-97f8-405a-a3a7-5ac467277521',
60
+ handle: '58f6f3c9-97f8-405a-a3a7-5ac467277521#03f003bc-7770-41c2-9217-aed966b578b1',
61
+ status: 200
62
+ },
63
+ {
64
+ id: '58f6f3c9-97f8-405a-a3a7-5ac467277522',
65
+ handle: '58f6f3c9-97f8-405a-a3a7-5ac467277521#03f003bc-7770-41c2-9217-aed966b578b2',
66
+ status: 200
67
+ },
68
+ {
69
+ id: '58f6f3c9-97f8-405a-a3a7-5ac467277523',
70
+ handle: '58f6f3c9-97f8-405a-a3a7-5ac467277521#03f003bc-7770-41c2-9217-aed966b578b3',
71
+ status: 4200
72
+ }
73
+ ])
74
+
75
+ expect(consoleErrorSpy).not.toHaveBeenCalled()
76
+ })
77
+
52
78
  test('Delete messages nothing to delete', async () => {
53
79
  sqs.deleteMessageBatch.mockResolvedValueOnce(getSampleDeleteMessageBatchResponse([]))
54
80
  const results = await deleteMessages('http://0.0.0.0:0000/queue', [
@@ -20,7 +20,7 @@ const deleteMessages = async (url, messageSubscriberResults) => {
20
20
  if (params.Entries.length) {
21
21
  const results = await sqs.deleteMessageBatch(params)
22
22
 
23
- if (results.Failed.length) {
23
+ if (results.Failed?.length) {
24
24
  console.error('Failed to delete messages from %s: %o', url, results.Failed)
25
25
  }
26
26