#!/bin/bash -x

set -euo pipefail

pushd "$(dirname "${BASH_SOURCE[0]}")/.." || exit 1

rm -rf testoutput
mkdir -p testoutput

docker-compose -f gotest-cron.yaml down --remove-orphans
docker-compose -f gotest-cron.yaml build --no-cache --pull
docker-compose -f gotest-cron.yaml up --abort-on-container-exit

exit_code=$(cat testoutput/test.sh.exit_code)

if [ "$exit_code" != "0" ]; then
        echo "tests did not succeed, exit code $exit_code"
        exit "$exit_code"
fi

popd || exit 1
