Files
docker-machine/test/integration/helpers.bash
T

51 lines
1.0 KiB
Bash
Raw Normal View History

2015-03-07 18:19:15 -05:00
#!/bin/bash
2015-12-07 15:43:16 +01:00
function echo_to_log {
echo "$BATS_TEST_NAME
2015-03-20 21:59:04 -04:00
----------
$output
----------
" >> ${BATS_LOG}
}
2015-12-07 15:43:16 +01:00
function teardown {
echo_to_log
}
2015-12-07 15:43:16 +01:00
function errecho {
>&2 echo "$@"
}
2015-12-07 15:43:16 +01:00
function only_if_env {
if [[ ${!1} != "$2" ]]; then
errecho "This test requires the $1 environment variable to be set to $2. Skipping..."
skip
fi
}
2015-12-07 15:43:16 +01:00
function require_env {
if [[ -z ${!1} ]]; then
errecho "This test requires the $1 environment variable to be set in order to run."
exit 1
fi
2015-03-20 21:59:04 -04:00
}
2015-08-27 19:07:39 +09:00
2015-12-07 17:13:13 +01:00
function use_disposable_machine {
if [[ -z "$NAME" ]]; then
export NAME="bats-$DRIVER-test-$(date +%s)"
fi
2015-12-07 15:43:16 +01:00
}
2015-12-07 17:13:13 +01:00
function use_shared_machine {
if [[ -z "$NAME" ]]; then
export NAME="$SHARED_NAME"
if [[ $(machine ls -q --filter name=$NAME | wc -l) -eq 0 ]]; then
machine create -d $DRIVER $NAME &>/dev/null
fi
2015-12-07 15:43:16 +01:00
fi
}
2015-08-27 19:07:39 +09:00
# Make sure these aren't set while tests run (can cause confusing behavior)
unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_DIR