Skip to content

Commit

Permalink
Add integ test and fix integ test
Browse files Browse the repository at this point in the history
Fix linting issues

Format file

Format file
  • Loading branch information
GavinZZ committed Aug 22, 2023
1 parent 200497b commit 8376a53
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def test_function_with_implicit_api_with_timeout(self):
rest_api_id = self.get_physical_id_by_type("AWS::ApiGateway::RestApi")
resources = apigw_client.get_resources(restApiId=rest_api_id)["items"]

method = apigw_client.get_method(restApiId=rest_api_id, resourceId=resources[0]["id"], httpMethod="GET")
resource = get_resource_by_path(resources, "/hello")
method = apigw_client.get_method(restApiId=rest_api_id, resourceId=resource["id"], httpMethod="GET")
method_integration = method["methodIntegration"]
self.assertEqual(method_integration["timeoutInMillis"], expected_timeout)


def get_resource_by_path(resources, path):
for resource in resources:
if resource["path"] == path:
return resource
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from integration.helpers.base_test import BaseTest


class TestFunctionWithIntrinsicsResourceAttributes(BaseTest):
def test_function_with_intrinsics_resource_attributes(self):
# simply verify the stack is deployed successfully is enough
self.create_and_verify_stack("combination/function_with_intrinsics_resource_attribute")

stack_outputs = self.get_stack_outputs()
id_dev_stack = stack_outputs["IsDevStack"]
self.assertEqual(id_dev_stack, "true")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"LogicalResourceId": "MyLambdaFunction",
"ResourceType": "AWS::Lambda::Function"
},
{
"LogicalResourceId": "MyLambdaFunctionRole",
"ResourceType": "AWS::IAM::Role"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
AWSTemplateFormatVersion: '2010-09-09'
Description: A template to test timeout support for implicit APIs.

Parameters:
IsDevStack: {Type: String, Default: 'true', AllowedValues: ['true', 'false']}
Conditions:
IsDevStack: !Equals [!Ref IsDevStack, 'true']
NotIsDevStack: !Not [Condition: IsDevStack]

Resources:
MyLambdaFunction:
DeletionPolicy: !If [NotIsDevStack, Retain, Delete]
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs16.x
MemorySize: 128
Timeout: 3
InlineCode: |
exports.handler = async () => 'Hello World!'
Outputs:
IsDevStack:
Value: !Ref IsDevStack

Metadata:
SamTransformTest: true

0 comments on commit 8376a53

Please sign in to comment.