mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
30 lines
678 B
JavaScript
30 lines
678 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 = () => {
|
|
const start = context.getRemainingTimeInMillis();
|
|
|
|
const stopAt = new Date().getTime() + 1;
|
|
while (new Date().getTime() < stopAt);
|
|
|
|
return Promise.resolve({
|
|
start,
|
|
stop: context.getRemainingTimeInMillis(),
|
|
});
|
|
};
|