#!/bin/sh

set -e -u

sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'cpsnow';"

CLEAN_USER=$(echo "$USER" | tr -dc '[a-z]')
sudo -u postgres psql -c "CREATE USER $CLEAN_USER WITH PASSWORD 'cpsnow';"
sudo -u postgres createdb -O "$CLEAN_USER" "$CLEAN_USER"

for py in $(py3versions -s); do
    echo "Running testsuite with $py:"
    $py -m pytest -x -v test/test_readme.py
done
