-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readme copied from AWS event mocks. Newlines
- Loading branch information
Showing
12 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 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](./lib/events) to learn more about the data structure of each event source. | ||
|
||
## Usage | ||
|
||
### SNS | ||
|
||
```js | ||
const createEvent = require('aws-event-mocks'); | ||
const mocked = createEvent({ | ||
template: 'aws:sns', | ||
merge: { | ||
Records: [{ | ||
Sns: { | ||
Message: 'trigger-email' | ||
} | ||
}] | ||
} | ||
}); | ||
``` | ||
|
||
### API Gateway | ||
|
||
```js | ||
const createEvent = require('aws-event-mocks'); | ||
const event = createEvent({ | ||
template: 'aws:apiGateway', | ||
merge: { | ||
body: { | ||
first_name: 'Sam', | ||
last_name: 'Smith' | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
### S3 | ||
|
||
```js | ||
const createEvent = require('aws-event-mocks'); | ||
const event = createEvent({ | ||
template: 'aws:s3', | ||
merge: { | ||
Records: [{ | ||
eventName: 'ObjectCreated:Put', | ||
s3: { | ||
bucket: { | ||
name: 'my-bucket-name' | ||
}, | ||
object: { | ||
key: 'object-key' | ||
} | ||
} | ||
}] | ||
} | ||
}); | ||
``` | ||
|
||
### Scheduled | ||
|
||
```js | ||
const createEvent = require('aws-event-mocks'); | ||
const event = createEvent({ | ||
template: 'aws:scheduled', | ||
merge: { | ||
region: 'us-west-2' | ||
} | ||
}); | ||
``` | ||
|
||
### Kinesis | ||
|
||
```js | ||
const createEvent = require('aws-event-mocks'); | ||
const event = createEvent({ | ||
template: 'aws:kinesis', | ||
merge: { | ||
data: new Buffer('this is test data').toString('base64') | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
declare module '*.json' { | ||
const value: any; | ||
export default value; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ | |
"user": "" | ||
}, | ||
"stageVariables": {} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ | |
"eventSource": "aws:dynamodb" | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
} | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ | |
} | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ | |
"arn:aws:events:us-east-1:123456789:rule/test-service-rule" | ||
], | ||
"detail": {} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ | |
} | ||
} | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ | |
"awsRegion": "us-east-2" | ||
} | ||
] | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
"semicolon": [true, "never"], | ||
"no-bitwise": false | ||
} | ||
} | ||
} |