#!/usr/bin/env bats
-setup() {
- # Run before each test case
- # Example: start container, prepare environment
+####################
+# Setup & Teardown #
+####################
+# setup_file is run once for this whole file
+setup_file() {
+
+ # Ensure sandboxed if the script has side effects.
+ if [ -z "$IN_CONTAINER" ]; then
+ echo "This script has side effects and must be run in a container." > /dev/stderr
+ exit 1
+ fi
+}
+
+# setup is run once per test case
+setup () {
+ # Source library
LIB_DIR="$(dirname $(dirname "$BATS_TEST_FILENAME"))/lib"
. "$LIB_DIR"/example.sh
}
+# teardown is run after each test case
teardown() {
- # Run after each test case
- # Example: stop/remove container, clean up resources
echo "Teardown running"
}
+#########
+# Tests #
+#########
@test "ensure echo_hello runs" {
echo_hello
}