0.1.2 • Published 8 years ago

lambda-tests v0.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

lambda-test

Build Status Code Climate Test Coverage

A library to simplify tests for AWS lambda functions written in Node.js

Installation

npm install lambda-tests

Dependencies

  • Node.js

Usage

Succeed Lambda

For a lambda that is expected to end with a context.succeed(result) call:

var runSucceedLambda = require("lambda-tests").runSucceedLambda;
var myLambda = require("my-lambda-function");

runSucceedLambda(myLambda, event, function(result) {
    //test expectations here
});

Fail Lambda

For a lambda that is expected to end with a context.fail(err) call:

var runFailLambda = require("lambda-tests").runFailLambda;
var myLambda = require("my-lambda-function");

runFailLambda(myLambda, event, function(err) {
    //test expectations here
});

Done Lambda

For a lambda that is expected to end with a context.done(err, result) call:

var runDoneLambda = require("lambda-tests").runDoneLambda;
var myLambda = require("my-lambda-function");

runDoneLambda(myLambda, event, function(err, result) {
    //test expectations here
});

Lambda

For a lambda that with no particular expected end state call:

var runLambda = require("lambda-tests").runLambda;
var myLambda = require("my-lambda-function");

runLambda(myLambda, event, function(err, result) {
    //test expectations here
});

Errors

UnexpectedEndStateError

If a lambda is tested with a specific context end state expectation, and another end state occurs, a UnexpectedEndStateError will be thrown.

MultipleEndStatesError

If a tested lambda hits multiple context end functions during its execution, it will throw this error. This error doesn't indicate a bug with the lambda function, it just indicates that the lambda function is incorrectly programmed to call multiple end states.

NoEndStateError

If a tested lambda never hits a context end functions during its execution, it will throw this error. This error doesn't indicate a bug with the lambda function, it just indicates that no end state was reached, which is not what lambda expects to happen.

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago