--- /dev/null
+#!/bin/bash
+set -eux
+TESTNAME=basic
+
+. _common.sh
+
+if $DISPENSE acct tpg; then
+ FAIL "Database contains '$USER'"
+fi
+
+sqlite3 "${BASEDIR}cokebank.db" "INSERT INTO accounts (acct_name,acct_is_admin,acct_uid) VALUES ('${USER}',1,1);"
+
+TRY_COMMAND "$DISPENSE user add unittest_user0"
+
+LOG "Checking for test user"
+TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'
+
+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
+TRY_COMMAND $DISPENSE acct unittest_user0 | grep ': $ 0.00'
+LOG "Success"
--- /dev/null
+
+BASEDIR=rundir/${TESTNAME}/
+PORT=22222
+
+mkdir -p ${BASEDIR}
+rm -f ${BASEDIR}cokebank.db
+
+cat << EOF > ${BASEDIR}cfg_server.conf
+# AUTOGENERATED Test ${TESTNAME}
+server_port ${PORT}
+cokebank_database ${BASEDIR}cokebank.db
+items_file ${BASEDIR}cfg_items.conf
+door_serial_port /dev/null
+
+coke_modbus_address 0.0.0.0
+coke_modbus_port 502
+test_mode no
+
+disable_syslog yes
+coke_dummy_mode yes
+EOF
+
+echo "# AUTOGENERATED Test ${TESTNAME}" > ${BASEDIR}cfg_items.conf
+
+LOG() {
+ echo "TEST ${TESTNAME}: "$*
+}
+FAIL() {
+ echo "TEST ${TESTNAME} FAIL: "$*
+ exit 1
+}
+TRY_COMMAND() {
+ cmd="$*"
+ if ! $cmd ; then
+ FAIL "Command \`$cmd\` failed"
+ fi
+}
+
+DISPENSE="../dispense -H localhost -P ${PORT}"
+
+LD_LIBRARY_PATH=.. ../dispsrv -f ${BASEDIR}cfg_server.conf --dont-daemonise > ${BASEDIR}server.log 2>&1 &
+server_pid=$!
+
+cleanup() {
+ LOG "Killing ${server_pid}"
+ kill ${server_pid}
+}
+trap cleanup EXIT
+
+LOG "Server running on PID ${server_pid}"
+sleep 1
+echo "" | nc localhost ${PORT}