test: cleaner helper file
This commit is contained in:
parent
a3ad7e6416
commit
682e85667a
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue