X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=tests%2FTEST_basic.sh;h=76c64903f8415b22fa4c29d29e5bf2bea5bda9a4;hb=4848b3853ef5517c4da4f2bcd6c8b959dae33411;hp=dccdc6d9b7be85d628c46c82e710837dba5a83af;hpb=0de1e8b33b746fa512d7ced5f5ef986c3b9b7dae;p=tpg%2Fopendispense2.git diff --git a/tests/TEST_basic.sh b/tests/TEST_basic.sh index dccdc6d..76c6490 100755 --- a/tests/TEST_basic.sh +++ b/tests/TEST_basic.sh @@ -1,17 +1,24 @@ #!/bin/bash -set -eux +set -eu TESTNAME=basic . _common.sh -# Ensure that the databse doesn't already contain the current user -# - 1. Protects against running the test against the production database -# - 2. Allows adding the current user as an admin -if $DISPENSE acct "$USER"; then - FAIL "Database contains '$USER'" +# (CI runs as root, and root is auto-added by databse creation) +if [[ "$USER" -ne "root" ]]; then + # Ensure that the databse doesn't already contain the current user + # - 1. Protects against running the test against the production database + # - 2. Allows adding the current user as an admin + if $DISPENSE acct "$USER"; then + FAIL "Database contains '$USER'" + fi + # Add the current user as an admin + sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);" +else + if $DISPENSE acct accmurph; then + FAIL "Database contains 'accmurph' (running as root, might be using prodution)" + fi fi -# Add the current user as an admin -sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);" # Try to add a new user TRY_COMMAND "$DISPENSE user add unittest_user0"