Skip to content

Commit 3aedcb9

Browse files
committed
Move cleanup to teardown_files() (fixes srvrco#696)
1 parent ecc91a4 commit 3aedcb9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

test/11-test--install.bats

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ setup() {
1515
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
1616
}
1717

18+
setup_file() {
19+
# Fail if not running in docker and /etc/getssl already exists
20+
TEST_FAILED=0
21+
if [ -d /etc/getssl ]; then
22+
echo "Test failed: /etc/getssl already exists" >&3
23+
TEST_FAILED=1
24+
touch $BATS_RUN_TMPDIR/failed.skip
25+
return 1
26+
fi
27+
}
28+
29+
teardown_file() {
30+
# Cleanup after tests
31+
if [ ${TEST_FAILED} == 0 ] && [ -d /etc/getssl ]; then
32+
rm -rf /etc/getssl
33+
fi
34+
}
35+
1836
@test "Check that config files in /etc/getssl works" {
1937
if [ -n "$STAGING" ]; then
2038
skip "Using staging server, skipping internal test"
@@ -23,9 +41,6 @@ setup() {
2341
CONFIG_FILE="getssl-http01.cfg"
2442
setup_environment
2543

26-
# Fail if not running in docker and /etc/getssl already exists
27-
refute [ -d /etc/getssl ]
28-
2944
# Create /etc/getssl/$DOMAIN
3045
mkdir -p /etc/getssl/${GETSSL_CMD_HOST}
3146

@@ -62,7 +77,4 @@ setup() {
6277
assert_line --partial 'copying domain certificate to'
6378
assert_line --partial 'copying private key to'
6479
assert_line --partial 'copying CA certificate to'
65-
66-
# Cleanup previous test
67-
rm -rf /etc/getssl
6880
}

0 commit comments

Comments
 (0)