Skip to content

Commit 0ea1ab9

Browse files
author
Rahul Kumar Singh
committed
fix: send continuation message to sqs in add step
1 parent ebd582b commit 0ea1ab9

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

src/common/audit-utils.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ export async function sendContinuationMessage(message, context) {
3636

3737
try {
3838
const { sqs } = context;
39-
await sqs.sendMessage({
40-
QueueUrl: queueUrl,
41-
MessageBody: JSON.stringify(payload),
42-
});
39+
await sqs.sendMessage(queueUrl, payload);
40+
41+
// await sqs.sendMessage({
42+
// QueueUrl: queueUrl,
43+
// MessageBody: JSON.stringify(payload),
44+
// });
4345
} catch (e) {
4446
log.error(`Failed to send message to queue ${queueUrl}`, e);
4547
throw e;

test/common/audit-utils.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,7 @@ describe('Audit Utils Tests', () => {
122122

123123
await sendContinuationMessage(message, context);
124124

125-
expect(context.sqs.sendMessage).to.have.been.calledWith({
126-
QueueUrl: message.queueUrl,
127-
MessageBody: JSON.stringify(message.payload),
128-
});
125+
expect(context.sqs.sendMessage).to.have.been.calledWith(message.queueUrl, message.payload);
129126
});
130127

131128
it('throws error when message sending fails', async () => {

test/common/step-audit.test.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,23 @@ describe('Step-based Audit Tests', () => {
176176
fullAuditRef: 's3://test/123',
177177
});
178178

179-
// Verify message sent to content scraper
180-
expect(context.sqs.sendMessage).to.have.been.calledWith({
181-
QueueUrl: 'https://space.cat/content-scraper',
182-
MessageBody: sinon.match.string,
183-
});
184-
185-
const sentMessage = JSON.parse(context.sqs.sendMessage.firstCall.args[0].MessageBody);
186-
expect(sentMessage).to.deep.include({
179+
// Update verification to match actual implementation
180+
const expectedPayload = {
187181
urls: [{ url: baseURL }],
188182
jobId: '42322ae6-b8b1-4a61-9c88-25205fa65b07',
183+
processingType: 'default',
189184
auditContext: {
190185
next: 'process',
191186
auditId: '109b71f7-2005-454e-8191-8e92e05daac2',
192187
auditType: 'content-audit',
193188
fullAuditRef: 's3://test/123',
194189
},
195-
});
190+
};
191+
192+
expect(context.sqs.sendMessage).to.have.been.calledWith(
193+
'https://space.cat/content-scraper',
194+
expectedPayload,
195+
);
196196
});
197197

198198
it('continues execution from specified step', async () => {
@@ -223,14 +223,8 @@ describe('Step-based Audit Tests', () => {
223223
// Verify no new audit record is created
224224
expect(context.dataAccess.Audit.create).not.to.have.been.called;
225225

226-
// Verify message sent to import worker
227-
expect(context.sqs.sendMessage).to.have.been.calledWith({
228-
QueueUrl: 'https://space.cat/import-worker',
229-
MessageBody: sinon.match.string,
230-
});
231-
232-
const sentMessage = JSON.parse(context.sqs.sendMessage.firstCall.args[0].MessageBody);
233-
expect(sentMessage).to.deep.include({
226+
// Update verification to match actual implementation
227+
const expectedPayload = {
234228
type: 'content-import',
235229
siteId: '42322ae6-b8b1-4a61-9c88-25205fa65b07',
236230
auditContext: {
@@ -239,7 +233,12 @@ describe('Step-based Audit Tests', () => {
239233
auditType: 'content-audit',
240234
fullAuditRef: 's3://test/123',
241235
},
242-
});
236+
};
237+
238+
expect(context.sqs.sendMessage).to.have.been.calledWith(
239+
'https://space.cat/import-worker',
240+
expectedPayload,
241+
);
243242
});
244243

245244
it('handles final step without sending messages', async () => {

0 commit comments

Comments
 (0)