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