forked from adamlaska/machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.bash
More file actions
50 lines (41 loc) · 1 KB
/
helpers.bash
File metadata and controls
50 lines (41 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
function echo_to_log {
echo "$BATS_TEST_NAME
----------
$output
----------
" >> ${BATS_LOG}
}
function teardown {
echo_to_log
}
function errecho {
>&2 echo "$@"
}
function only_if_env {
if [[ ${!1} != "$2" ]]; then
errecho "This test requires the $1 environment variable to be set to $2. Skipping..."
skip
fi
}
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
}
function use_disposable_machine {
if [[ -z "$NAME" ]]; then
export NAME="bats-$DRIVER-test-$(date +%s)"
fi
}
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
fi
}
# Make sure these aren't set while tests run (can cause confusing behavior)
unset DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_DIR