Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions tests/integration/local/invoke/test_integrations_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,48 @@ def test_invoke_with_docker_network_of_host(self):

self.assertEquals(return_code, 0)

def test_invoke_with_docker_network_of_host_in_env_var(self):
command_list = self.get_command_list("HelloWorldServerlessFunction",
template_path=self.template_path,
event_path=self.event_path)

env = os.environ.copy()
env["SAM_DOCKER_NETWORK"] = 'non-existing-network'

process = Popen(command_list, stderr=PIPE, env=env)
process.wait()
process_stderr = b"".join(process.stderr.readlines()).strip()

self.assertIn('Not Found ("network non-existing-network not found")', process_stderr.decode('utf-8'))

def test_sam_template_file_env_var_set(self):
command_list = self.get_command_list("HelloWorldFunctionInNonDefaultTemplate", event_path=self.event_path)

self.test_data_path.joinpath("invoke", "sam-template.yaml")
env = os.environ.copy()
env["SAM_TEMPLATE_FILE"] = str(self.test_data_path.joinpath("invoke", "sam-template.yaml"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice :)


process = Popen(command_list, stdout=PIPE, env=env)
process.wait()
process_stdout = b"".join(process.stdout.readlines()).strip()

self.assertEquals(process_stdout.decode('utf-8'), '"Hello world"')

def test_skip_pull_image_in_env_var(self):
docker.from_env().api.pull('lambci/lambda:python3.6')

command_list = self.get_command_list("HelloWorldLambdaFunction",
template_path=self.template_path,
event_path=self.event_path)

env = os.environ.copy()
env["SAM_SKIP_PULL_IMAGE"] = "True"

process = Popen(command_list, stderr=PIPE, env=env)
process.wait()
process_stderr = b"".join(process.stderr.readlines()).strip()
self.assertIn("Requested to skip pulling images", process_stderr.decode('utf-8'))


class TestUsingConfigFiles(InvokeIntegBase):
template = Path("template.yml")
Expand Down Expand Up @@ -502,6 +544,23 @@ def test_caching_two_layers(self):

self.assertEquals(2, len(os.listdir(str(self.layer_cache))))

def test_caching_two_layers_with_layer_cache_env_set(self):

command_list = self.get_command_list("TwoLayerVersionServerlessFunction",
template_path=self.template_path,
no_event=True,
region=self.region,
parameter_overrides=self.layer_utils.parameters_overrides
)

env = os.environ.copy()
env["SAM_LAYER_CACHE_BASEDIR"] = str(self.layer_cache)

process = Popen(command_list, stdout=PIPE, env=env)
process.wait()

self.assertEquals(2, len(os.listdir(str(self.layer_cache))))


@skipIf(SKIP_LAYERS_TESTS,
"Skip layers tests in Travis only")
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/testdata/invoke/sam-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.

Resources:
HelloWorldFunctionInNonDefaultTemplate:
Type: AWS::Serverless::Function
Properties:
Handler: main.handler
Runtime: python3.6
CodeUri: .
Timeout: 600