serverless/aws-event-mocks

Name: aws-event-mocks

Owner: Serverless

Description: null

Created: 2016-09-28 06:07:23.0

Updated: 2018-05-10 02:29:14.0

Pushed: 2017-10-25 06:42:43.0

Homepage: null

Size: 14

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

AWS Event Mocks

A small library that includes details mocks of AWS Lambda event sources. Useful for use when unit testing your Lambda functions. Supported Event Sources are: SNS, API Gateway, S3, & Scheduled.

The library simply uses default event source mock templates and merge it with any overwrite you provide. Check out the JSON template files to learn more about the data structure of each event source.

Usage
SNS
t createEvent = require('aws-event-mocks');
t mocked = createEvent({
mplate: 'aws:sns',
rge: {
Records: [{
  Sns: {
    Message: 'trigger-email'
  }
}]


API Gateway
t createEvent = require('aws-event-mocks');
t event = createEvent({
mplate: 'aws:apiGateway',
rge: {
body: {
  first_name: 'Sam',
  last_name: 'Smith'
}


S3
t createEvent = require('aws-event-mocks');
t event = createEvent({
mplate: 'aws:s3',
rge: {
Records: [{
  eventName: 'ObjectCreated:Put',
  s3: {
    bucket: {
      name: 'my-bucket-name'
    },
    object: {
      key: 'object-key'
    }
  }
}]


Scheduled
t createEvent = require('aws-event-mocks');
t event = createEvent({
mplate: 'aws:scheduled',
rge: {
region: 'us-west-2'


Kinesis
t createEvent = require('aws-event-mocks');
t event = createEvent({
mplate: 'aws:kinesis',
rge: {
data: new Buffer('this is test data').toString('base64')



This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.