Emmanuel BENOîT
be3106c463
* Added in-base logging through a foreign data wrapper, which is only possible using PostgreSQL 9.1 * Renamed database-related configuration files to indicate that they are samples, and added the "real" names to the Git ignore list. Server distribution modified accordingly. * Removed PL/PgSQL registration (it was only necessary on 8.4) * Added pgTAP SQL definitions and a script which will (hopefully) be executed by the build system after the main Java build in order to execute database unit tests. The script supports both admin- and user- level testing. I also added a few tests to make sure the testing framework actually runs them. * Added documentation about the database definitions structure
55 lines
1.4 KiB
Bash
Executable file
55 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
cd legacyworlds-server-data/db-structure
|
|
if ! [ -f db-config.txt ]; then
|
|
cat > db-config.txt <<EOF
|
|
admin=$USER
|
|
db=tests
|
|
user=tests
|
|
password=tests
|
|
EOF
|
|
fi
|
|
TEST_DATABASE="`grep ^db= db-config.txt | sed -e s/.*=//`"
|
|
TEST_USER="`grep ^user= db-config.txt | sed -e s/.*=//`"
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "LOADING DATABASE DEFINITION ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
psql -vQUIET=1 -vON_ERROR_STOP=1 -e --file database.sql || exit 1
|
|
|
|
if ! [ -d tests/admin ] && ! [ -d tests/user ]; then
|
|
echo
|
|
echo
|
|
echo "WARNING: no unit tests to run"
|
|
echo
|
|
echo
|
|
exit 0
|
|
fi
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "LOADING TEST FRAMEWORK ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
psql -vQUIET=1 -f tests/pgtap.sql $TEST_DATABASE || exit 1
|
|
|
|
echo
|
|
echo
|
|
echo "======================================================================"
|
|
echo "RUNNING DATABASE TESTS ..."
|
|
echo "======================================================================"
|
|
echo
|
|
echo
|
|
cd tests
|
|
if [ -d admin ]; then
|
|
pg_prove -d $TEST_DATABASE `find admin/ -type f -name '*.sql'` || exit 1
|
|
fi
|
|
if [ -d user ]; then
|
|
pg_prove -U $TEST_USER -d $TEST_DATABASE `find user/ -type f -name '*.sql'` || exit 1
|
|
fi
|