diff options
Diffstat (limited to 'test/travis-prepare.sh')
-rwxr-xr-x | test/travis-prepare.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/travis-prepare.sh b/test/travis-prepare.sh new file mode 100755 index 0000000..7a303e8 --- /dev/null +++ b/test/travis-prepare.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -ex + +: "${DIRECTOR_TESTDB:=director_test}" + +psql_cmd() { + psql -U postgres ${DIRECTOR_TESTDB} -q -c "$@" +} + +if [ "$DB" = mysql ]; then + mysql -u root -e "DROP DATABASE IF EXISTS ${DIRECTOR_TESTDB}; CREATE DATABASE ${DIRECTOR_TESTDB};" +elif [ "$DB" = pgsql ]; then + : "${DIRECTOR_TESTDB_USER:=director_test}" + + psql -U postgres postgres -q -c "DROP DATABASE IF EXISTS ${DIRECTOR_TESTDB};" + psql -U postgres postgres -q -c "CREATE DATABASE ${DIRECTOR_TESTDB} WITH ENCODING 'UTF8';" + psql_cmd "CREATE USER ${DIRECTOR_TESTDB_USER} WITH PASSWORD 'testing';" + psql_cmd "GRANT ALL PRIVILEGES ON DATABASE ${DIRECTOR_TESTDB} TO ${DIRECTOR_TESTDB_USER};" + psql_cmd "CREATE EXTENSION pgcrypto;" +else + echo "Unknown database set in environment!" >&2 + env + exit 1 +fi |