Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
node-version: [18, 20]
node-version: [18, 20, 22]
uses: driimus/shared-workflows/.github/workflows/test.yml@main
with:
node-version: ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20
lts/jod
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"@faker-js/faker": "^9.0.1",
"@tsconfig/node-lts": "^20.1.3",
"@tsconfig/strictest": "^2.0.5",
"@types/aws-lambda": "^8.10.131",
"@types/node": "^20.16.5",
"@types/aws-lambda": "^8.10.146",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@vitest/coverage-v8": "^2.0.0",
"@vitest/eslint-plugin": "^1.1.4",
"@vitest/coverage-v8": "^2.1.8",
"@vitest/eslint-plugin": "^1.1.16",
"eslint": "^9.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import-x": "^4.3.0",
Expand All @@ -40,9 +40,9 @@
"turbo": "^2.0.1",
"typescript": "^5.3.3",
"typescript-eslint": "^8.7.0",
"vitest": "^2.0.0"
"vitest": "^2.1.8"
},
"packageManager": "pnpm@9.11.0",
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">=18.18.2"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-event-factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"peerDependencies": {
"@faker-js/faker": "^9.0.1",
"@types/aws-lambda": "^8.10.131",
"@types/aws-lambda": "^8.10.146",
"fishery": "^2.2.2"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lambda-batch-processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@driimus/aws-event-factory": "workspace:*"
},
"peerDependencies": {
"@types/aws-lambda": "^8.10.131"
"@types/aws-lambda": "^8.10.146"
},
"peerDependenciesMeta": {
"@types/aws-lambda": {
Expand Down
9 changes: 4 additions & 5 deletions packages/sqs-permanent-failure-dlq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
"test": "vitest run --coverage.thresholds.100"
},
"devDependencies": {
"@aws-sdk/client-sqs": "^3.226.0",
"@aws-sdk/client-sqs": "^3.709.0",
"@driimus/aws-event-factory": "workspace:*",
"@driimus/lambda-batch-processor": "workspace:*",
"aws-sdk-client-mock": "^3.0.0",
"aws-sdk-client-mock-jest": "^3.0.0"
"aws-sdk-client-mock": "^4.1.0"
},
"peerDependencies": {
"@aws-sdk/client-sqs": "^3.226.0",
"@types/aws-lambda": "^8.10.131"
"@aws-sdk/client-sqs": "^3.709.0",
"@types/aws-lambda": "^8.10.146"
},
"peerDependenciesMeta": {
"@types/aws-lambda": {
Expand Down
24 changes: 12 additions & 12 deletions packages/sqs-permanent-failure-dlq/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ import { FailureAccumulator, SQSBatchProcessor } from '@driimus/lambda-batch-pro
import { faker } from '@faker-js/faker';
import type { SQSRecord } from 'aws-lambda';
import { mockClient } from 'aws-sdk-client-mock';
import mockJestMatchers from 'aws-sdk-client-mock-jest';
import { Factory } from 'fishery';
import { beforeEach, describe, expect, it, vi } from 'vitest';

import { PermanentFailureDLQHandler } from '../src/index.js';

expect.extend(mockJestMatchers);

const mockSQS = mockClient(SQSClient);

beforeEach(() => {
Expand Down Expand Up @@ -57,11 +54,15 @@ describe('PermanentFailureDLQHandler', () => {
mockSQS.resolves({});

await expect(toDLQHandler.handleRejections(failures)).resolves.toBeUndefined();
expect(mockSQS).toHaveReceivedCommandTimes(SendMessageBatchCommand, 1);
expect(mockSQS).toHaveReceivedCommandWith(SendMessageBatchCommand, {
QueueUrl: queueUrl,
Entries: expect.objectContaining({ length: failures.permanentFailures.length }),
});
expect(mockSQS.commandCalls(SendMessageBatchCommand)).toHaveLength(1);
expect(mockSQS.commandCalls(SendMessageBatchCommand).at(0)?.args).toMatchObject([
{
input: {
QueueUrl: queueUrl,
Entries: expect.objectContaining({ length: failures.permanentFailures.length }),
},
},
]);
});

it('should surface rejections', async () => {
Expand All @@ -70,7 +71,7 @@ describe('PermanentFailureDLQHandler', () => {
const surfacePermanentFailures = vi.spyOn(failures, 'surfacePermanentFailures');

await expect(toDLQHandler.handleRejections(failures)).resolves.toBeUndefined();
expect(mockSQS).toHaveReceivedCommandTimes(SendMessageBatchCommand, 1);
expect(mockSQS.commandCalls(SendMessageBatchCommand)).toHaveLength(1);
expect(surfacePermanentFailures).toHaveBeenCalled();
});

Expand All @@ -80,7 +81,7 @@ describe('PermanentFailureDLQHandler', () => {
await expect(
toDLQHandler.handleRejections(accumulatorFactory.build({ permanentFailures: [] })),
).resolves.toBeUndefined();
expect(mockSQS).not.toHaveReceivedCommand(SendMessageBatchCommand);
expect(mockSQS.commandCalls(SendMessageBatchCommand)).toHaveLength(0);
});

it('should move messages in batches of 10', async () => {
Expand All @@ -93,8 +94,7 @@ describe('PermanentFailureDLQHandler', () => {
await expect(
toDLQHandler.handleRejections(accumulatorFactory.build({ permanentFailures })),
).resolves.toBeUndefined();
expect(mockSQS).toHaveReceivedCommandTimes(
SendMessageBatchCommand,
expect(mockSQS.commandCalls(SendMessageBatchCommand)).toHaveLength(
Math.ceil(permanentFailures.length / 10),
);
});
Expand Down
Loading
Loading