From a4f851db571e9532be6da7f7fc888c87eed38d6d Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Mon, 17 Jun 2019 13:59:58 +0200 Subject: [PATCH] Integration tests that covers integration lambda timeout --- tests/integration-all/api-gateway/service/core.js | 11 +++++++++++ .../api-gateway/service/serverless.yml | 8 ++++++++ tests/integration-all/api-gateway/tests.js | 6 ++++++ 3 files changed, 25 insertions(+) diff --git a/tests/integration-all/api-gateway/service/core.js b/tests/integration-all/api-gateway/service/core.js index 326d614cb..aa19d4084 100644 --- a/tests/integration-all/api-gateway/service/core.js +++ b/tests/integration-all/api-gateway/service/core.js @@ -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, }; diff --git a/tests/integration-all/api-gateway/service/serverless.yml b/tests/integration-all/api-gateway/service/serverless.yml index 75bdd3fd2..68be27ed3 100644 --- a/tests/integration-all/api-gateway/service/serverless.yml +++ b/tests/integration-all/api-gateway/service/serverless.yml @@ -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 diff --git a/tests/integration-all/api-gateway/tests.js b/tests/integration-all/api-gateway/tests.js index bdd1d5578..89adb9a73 100644 --- a/tests/integration-all/api-gateway/tests.js +++ b/tests/integration-all/api-gateway/tests.js @@ -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))); + }); });