Commit a7537ff3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

test: cleaner helper file

parent 1cfffaf3
......@@ -8,9 +8,7 @@ load test_helper
fixtures amazon-ebs
teardown() {
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
aws_ami_cleanup
}
@test "build minimal.json" {
......
......@@ -7,12 +7,9 @@ for cmd in "${required[@]}"; do
}
done
# This sets the directory for fixtures by specifying the name of
# the folder with fixtures.
fixtures() {
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures/$1"
}
#--------------------------------------------------------------------
# Bats modification
#--------------------------------------------------------------------
# This allows us to override a function in Bash
save_function() {
local ORIG_FUNC=$(declare -f $1)
......@@ -30,3 +27,19 @@ run() {
echo $line
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