123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/bin/bash
- set -e
- # Create the database that will be used by the fixtures, populating it with the
- # default data. Also create a test dak directory.
- # After that, run all dbtests
- # At the end, clean up.
- DAK_ROOT="$(cd $(dirname "$0")/..; pwd)"
- export PGDATABASE=test_projectb
- if [[ ! -v DAK_INTEGRATION_TEST ]]; then
- SYS_CMD="sudo"
- KEEP_ENV_OPT="-E"
- USER_CMD="sudo -u dak PGDATABASE=${PGDATABASE} DAKBASE=${DAKBASE}"
- else
- SYS_CMD=""
- KEEP_ENV_OPT=""
- USER_CMD=""
- fi
- test-setup() {
- # Create the database as expected by the tests
- export DAKBASE=${DAK_ROOT}/tests/fixtures/tmpdak
- ${DAK_ROOT}/setup/dak-setup.sh
- }
- test-cleanup() {
- echo Dropping DB ${PGDATABASE}
- $USER_CMD $KEEP_ENV_OPT dropdb ${PGDATABASE}
- echo Deleting temporary directory
- $SYS_CMD rm -rf -- ${DAKBASE}
- }
- # Unless --nocleanup is passed, the script will cleanup at the end.
- if [[ "$1" != "--nocleanup" ]]; then
- trap test-cleanup EXIT
- fi
- test-setup
- $USER_CMD ${DAK_ROOT}/tests/dbtest_all.py
|