#!/usr/bin/env bash
#
# This script is designed to be run inside the container
#

# fail hard and fast even on pipelines
set -eou pipefail

function creating_rsa_key() {
    mkdir -p /var/run/secrets/drycc/passport/ \
      && openssl genrsa -out /var/run/secrets/drycc/passport/oidc-rsa-private-key 4096
}

gosu postgres pg_ctl -D "$PGDATA" start && ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432
creating_rsa_key
python3 manage.py check
coverage run manage.py test --settings=api.settings.testing --noinput api
coverage report -m
