1.0.12 • Published 7 years ago

@philca/lambda-test-utils v1.0.12

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

API

loadDynamo(< tablename>, < data>)

Load a table with a record.

Returns: a promise.

Where:

tablename: name of dynamo table
data: json object of data.
If data is an array, each item in the array will be loaded.

deleteDynamo(< primarykey field>, < primary key value>, sort key field, sort key value)

Delete an item from a dynamo table.

Returns: a promise.

Where:

tablename: name of dynamo table
primarykey field: field name of primary key
primarykey value: value for primary key
sortkey field: (optional) field name of sort key
sortkey value: (optional) value for sort key

getAndDeleteItemsFromDynamo(< tablename>, < primarykey field>, < primary key value>, sort key field)

Gets one or more items from a dynamo table, returns them, and deletes them. Use this function to get the items created by the lambda under test and clean them up.

Note: This is an async function. Called like:

const addedLoki = await getAndDeleteItemsFromDynamo(process.env.DYNAMO_LOKI_TABLE, res.body.lokiId);

or

const addedMetadata = await getAndDeleteItemsFromDynamo(process.env.DYNAMO_METADATA_TABLE, 'entityKey', res.body.lokiId, 'metavalueKey');

Returns: a json object that contains an array or Items.

Where:

tablename: name of dynamo table
primarykey field: field name of primary key
primarykey value: value for primary key
sortkey field: (optional) field name of sort key

invokeLambda(< lambda name>, < event>, < path>)

Execute a lambda function.

If the environment variable LOCAL_LAMBDA is true, the lambda will be run locally, else the lambda within AWS (in your default account) will be run.

let res = await invokeLambda('golokiImages-getimagelabels', event, __dirname);

Returns: a promise.

Where:

lambda_name: The name of the lambda_name
event: The json event passed to the lambda. Like:

const event = {
	"queryStringParameters": {},
	"pathParameters": {
		"foo": "bar"
	},
	"body": null
};

path: path to the local lambda handler. Assumes index.js in the path contains the handler.

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago