7 # Ensure that the databse doesn't already contain the current user
8 # - 1. Protects against running the test against the production database
9 # - 2. Allows adding the current user as an admin
10 if $DISPENSE acct "$USER"; then
11 FAIL "Database contains '$USER'"
13 # Add the current user as an admin
14 sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);"
16 # Try to add a new user
17 TRY_COMMAND "$DISPENSE user add unittest_user0"
19 # Ensure that the add worked
20 LOG "Checking for test user"
21 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'
23 # Manipulate user's balance
24 TRY_COMMAND $DISPENSE acct unittest_user0 +100 Unit_test
25 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 1.00'
26 TRY_COMMAND $DISPENSE acct unittest_user0 -100 Unit_test
27 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'