#!/bin/sh

set -e

# Disable the mysql test suite for now, we only run the postgres test suite
# The limitation is that both database engines run (as one would expect) as
# different users and therefore local identification via the uid works either
# for one or the other, so the case hereunder is executed against postgres with
# the postgres user and in that execution the mysql test cases could not be run
# without further changes to the test_databases.ini file and to the default
# mysql setup.
sed -i '/mysql/d' test_databases.ini

# also change the user in the db URI for the test
sed -i "s/postgres@/$USER@/" test_databases.ini

for py in $(py3versions -s); do
  # create private PG cluster for testing
  pg_virtualenv -i "-U$USER -Atrust" <<EOF
set -ex
export PYTHONPATH=$(pwd)/debian/tests
psql -U$USER -c 'create database yoyo_test;'
$py -m pytest yoyo/tests
EOF

done
