Skip to content

Instantly share code, notes, and snippets.

@mtimbs
Created March 11, 2020 00:32
Show Gist options
  • Save mtimbs/1b93e94b0eb2541f622f754976991758 to your computer and use it in GitHub Desktop.
Save mtimbs/1b93e94b0eb2541f622f754976991758 to your computer and use it in GitHub Desktop.
Utility for generating fake SQS Records to help with Unit/Integration testing
import { v4 as uuidv4 } from 'uuid';
import { SQSRecord } from 'aws-lambda';
const now = Math.round((new Date()).getTime() / 1000).toString();
export default (params?: Partial<SQSRecord>): SQSRecord => ({
messageId: uuidv4(),
receiptHandle: uuidv4(),
body: '',
attributes: {
ApproximateReceiveCount: '1',
SentTimestamp: now,
SenderId: uuidv4(),
ApproximateFirstReceiveTimestamp: now,
},
messageAttributes: {},
md5OfBody: 'rarely-actually-need-this',
eventSource: 'aws:sqs',
eventSourceARN: 'arn:aws:sqs:my-region:account-number:queue-name',
awsRegion: 'my-region',
...params,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment