7 # (CI runs as root, and root is auto-added by databse creation)
8 if [[ "x$USER" != "xroot" ]]; then
9 # Ensure that the databse doesn't already contain the current user
10 # - 1. Protects against running the test against the production database
11 # - 2. Allows adding the current user as an admin
12 if $DISPENSE acct "$USER"; then
13 FAIL "Database contains '$USER'"
15 # Add the current user as an admin
16 sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);"
18 if $DISPENSE acct accmurph; then
19 FAIL "Database contains 'accmurph' (running as root, might be using prodution)"
23 # Try to add a new user
24 TRY_COMMAND "$DISPENSE user add unittest_user0"
26 # Ensure that the add worked
27 LOG "Checking for test user"
28 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'
30 # Manipulate user's balance
31 TRY_COMMAND $DISPENSE acct unittest_user0 +100 Unit_test
32 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 1.00'
33 TRY_COMMAND $DISPENSE acct unittest_user0 -100 Unit_test
34 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'