serverless/lib/plugins/aws/invokeLocal/fixture/asyncHandlerWithSuccess.js
Lewis Chung 68e4460451 Make adjustments
- Use lodash to check thennable
- Add arguments back into lambda context fixture
2018-04-30 09:28:35 -07:00

30 lines
692 B
JavaScript

'use strict';
module.exports.withErrorByDone = () => Promise.reject(new Error('failed'));
module.exports.withMessageByDone = () => Promise.resolve('Succeed');
module.exports.withMessageByLambdaProxy = () =>
Promise.resolve({
statusCode: 200,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
result: true,
message: 'Whatever',
}),
});
module.exports.withRemainingTime = (event, context) => {
const start = context.getRemainingTimeInMillis();
const stopAt = new Date().getTime() + 1;
while (new Date().getTime() < stopAt);
return Promise.resolve({
start,
stop: context.getRemainingTimeInMillis(),
});
};