weblate/ci/lib
Michal Čihař 8a215fa59f CI: Generalize setup
- specify database host in the environment
- run migration test on current database instead of iterating over all

Signed-off-by: Michal Čihař <michal@cihar.com>
2019-08-09 12:20:53 +02:00

31 lines
925 B
Text

# shell library to help executing tests
set -x
coverage erase
check() {
RET=$?
if [ $RET -ne 0 ] ; then
exit $RET
fi
}
run_coverage() {
python -W default -W ignore:unclosed:ResourceWarning -m coverage run --source . --append "$@"
}
cleanup_database() {
rm -f weblate.db
if [ $CI_DATABASE = "mysql" ] ; then
mysql --host=$CI_DB_HOST -e 'SET GLOBAL character_set_server=utf8' -uroot
mysql --host=$CI_DB_HOST -e 'SET GLOBAL collation_server=utf8_general_ci' -uroot
mysql --host=$CI_DB_HOST -e 'DROP DATABASE IF EXISTS weblate;' -uroot
mysql --host=$CI_DB_HOST -e 'CREATE DATABASE weblate CHARACTER SET utf8 COLLATE utf8_general_ci;' -uroot
fi
if [ $CI_DATABASE = "postgresql" ] ; then
psql --host=$CI_DB_HOST -c 'DROP DATABASE IF EXISTS weblate;' -U postgres
psql --host=$CI_DB_HOST -c 'CREATE DATABASE weblate;' -U postgres
fi
}