From 0de1e8b33b746fa512d7ced5f5ef986c3b9b7dae Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 19 Sep 2021 14:32:54 +0800 Subject: [PATCH] tests - Tweak tests in preparation for attempted CI --- tests/TEST_basic.sh | 10 ++++++++-- tests/_common.sh | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/TEST_basic.sh b/tests/TEST_basic.sh index f2f1301..dccdc6d 100755 --- a/tests/TEST_basic.sh +++ b/tests/TEST_basic.sh @@ -4,17 +4,23 @@ TESTNAME=basic . _common.sh -if $DISPENSE acct tpg; 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);" +# Try to add a new user TRY_COMMAND "$DISPENSE user add unittest_user0" +# Ensure that the add worked LOG "Checking for test user" TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00' +# Manipulate user's balance TRY_COMMAND $DISPENSE acct unittest_user0 +100 Unit_test TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 1.00' TRY_COMMAND $DISPENSE acct unittest_user0 -100 Unit_test diff --git a/tests/_common.sh b/tests/_common.sh index 0019b99..4058bb5 100644 --- a/tests/_common.sh +++ b/tests/_common.sh @@ -1,10 +1,13 @@ - +# +# NOTE: Not a script, to be included by scripts +# BASEDIR=rundir/${TESTNAME}/ PORT=22222 mkdir -p ${BASEDIR} rm -f ${BASEDIR}cokebank.db +# Template configuration (disables door and the coke machine) cat << EOF > ${BASEDIR}cfg_server.conf # AUTOGENERATED Test ${TESTNAME} server_port ${PORT} -- 2.20.1