Created
March 11, 2020 00:32
-
-
Save mtimbs/1b93e94b0eb2541f622f754976991758 to your computer and use it in GitHub Desktop.
Utility for generating fake SQS Records to help with Unit/Integration testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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