481e1198452afaaee5a615e8aa57b39ff39c6fa1
[tpg/opendispense2.git] / tests / TEST_basic.sh
1 #!/bin/bash
2 set -eu
3 TESTNAME=basic
4
5 . _common.sh
6
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'"
12 fi
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);"
15
16 # Try to add a new user
17 TRY_COMMAND "$DISPENSE user add unittest_user0"
18
19 # Ensure that the add worked
20 LOG "Checking for test user"
21 TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $    0.00'
22
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'
28 LOG "Success"

UCC git Repository :: git.ucc.asn.au