Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SQS receive message middleware properly calls next() once #1680

Merged
merged 1 commit into from Nov 13, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/middleware-sdk-sqs/src/receive-message.ts
Expand Up @@ -44,9 +44,7 @@ export function receiveMessageMiddleware(options: PreviouslyResolved): Initializ
throw new Error("Invalid MD5 checksum on messages: " + messageIds.join(", "));
}

return next({
...args,
});
return resp;
};
}

Expand Down
16 changes: 16 additions & 0 deletions packages/middleware-sdk-sqs/src/receive-messages.spec.ts
Expand Up @@ -14,6 +14,22 @@ describe("receiveMessageMiddleware", () => {
mockHashDigest.mockClear();
});

it("should only call next once", async () => {
const next = jest.fn().mockReturnValue({
output: {
Messages: [
{ Body: "foo", MD5OfBody: "00", MessageId: "fooMessage" },
{ Body: "bar", MD5OfBody: "00", MessageId: "barMessage" },
],
},
});
const handler = receiveMessageMiddleware({
md5: MockHash,
})(next, {} as any);
await handler({ input: {} });
expect(next).toBeCalledTimes(1);
});

it("should do nothing if the checksums match", async () => {
const next = jest.fn().mockReturnValue({
output: {
Expand Down