Skip to content

Commit

Permalink
fixup! [wip] Add tests using AWS' SAM CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Apr 11, 2024
1 parent b3c2919 commit 25b091b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 0 additions & 2 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ services:
- BUGSNAG_API_KEY
- BUGSNAG_ERROR_ENDPOINT
- BUGSNAG_SESSION_ENDPOINT
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./aws-lambda/app:/usr/src/app"
12 changes: 11 additions & 1 deletion features/steps/steps.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
require "os"

# PYTHON_TEST_VERSION is defined in env.rb
PARAMETER_OVERRIDES = "--parameter-overrides ParameterKey=Runtime,ParameterValue=python#{PYTHON_TEST_VERSION}"

def current_ip
return "host.docker.internal" if OS.mac?

ip_addr = `ifconfig | grep -Eo 'inet (addr:)?([0-9]*\\\.){3}[0-9]*' | grep -v '127.0.0.1'`
ip_list = /((?:[0-9]*\.){3}[0-9]*)/.match(ip_addr)
ip_list.captures.first
end

Given("I build the {string} lambda") do |lambda_name|
step(%Q{I run the service "aws-lambda" with the command "sam build #{lambda_name} #{PARAMETER_OVERRIDES}"})
end

Given("I invoke the {string} lambda") do |lambda_name|
command = [
"sam local invoke #{lambda_name}",
"--container-host host.docker.internal",
"--container-host #{current_ip}",
"--docker-volume-basedir $PWD/features/fixtures/aws-lambda/app/.aws-sam/build",
PARAMETER_OVERRIDES,
]
Expand Down

0 comments on commit 25b091b

Please sign in to comment.