Integration tests that covers integration lambda timeout

This commit is contained in:
Mariusz Nowak 2019-06-17 13:59:58 +02:00
parent 5282cab708
commit a4f851db57
No known key found for this signature in database
GPG Key ID: B1FBDA8A182B03F2
3 changed files with 25 additions and 0 deletions

View File

@ -43,9 +43,20 @@ async function apiKeys(event) {
};
}
async function timeout(event) {
return new Promise(resolve => setTimeout(() => resolve({
statusCode: 200,
body: JSON.stringify({
message: 'Should not happen (timeout expected)',
event,
}),
}), 2000));
}
module.exports = {
minimal,
cors,
customAuthorizers,
apiKeys,
timeout,
};

View File

@ -57,6 +57,14 @@ functions:
path: api-keys
method: GET
private: true
timeout:
handler: core.timeout
timeout: 1
events:
- http:
method: GET
integration: lambda
path: integration-lambda-timeout
# helper functions
authorizer:
handler: helper.auth

View File

@ -264,4 +264,10 @@ describe('AWS - API Gateway Integration Test', () => {
.then((json) => expect(json.message).to.equal('Hello from API Gateway! - (minimal)'));
});
});
describe('Integration Lambda Timeout', () => {
it('should result with 504 status code',
() => fetch(`${endpoint}/integration-lambda-timeout`)
.then(response => expect(response.status).to.equal(504)));
});
});