Commit a7537ff3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

test: cleaner helper file

parent 1cfffaf3
...@@ -8,9 +8,7 @@ load test_helper ...@@ -8,9 +8,7 @@ load test_helper
fixtures amazon-ebs fixtures amazon-ebs
teardown() { teardown() {
aws ec2 describe-images --owners self --output json --filters 'Name=tag:packer-test,Values=true' \ aws_ami_cleanup
| jq -r -M '.Images[]["ImageId"]' \
| xargs -n1 aws ec2 deregister-image --image-id
} }
@test "build minimal.json" { @test "build minimal.json" {
......
...@@ -7,12 +7,9 @@ for cmd in "${required[@]}"; do ...@@ -7,12 +7,9 @@ for cmd in "${required[@]}"; do
} }
done done
# This sets the directory for fixtures by specifying the name of #--------------------------------------------------------------------
# the folder with fixtures. # Bats modification
fixtures() { #--------------------------------------------------------------------
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
}
# This allows us to override a function in Bash # This allows us to override a function in Bash
save_function() { save_function() {
local ORIG_FUNC=$(declare -f $1) local ORIG_FUNC=$(declare -f $1)
...@@ -30,3 +27,19 @@ run() { ...@@ -30,3 +27,19 @@ run() {
echo $line echo $line
done done
} }
#--------------------------------------------------------------------
# Helper functions
#--------------------------------------------------------------------
# This sets the directory for fixtures by specifying the name of
# the folder with fixtures.
fixtures() {
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
}
# This deletes any AMIs with a tag "packer-test" of "true"
aws_ami_cleanup() {
aws ec2 describe-images --owners self --output json --filters 'Name=tag:packer-test,Values=true' \
| jq -r -M '.Images[]["ImageId"]' \
| xargs -n1 aws ec2 deregister-image --image-id
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment