2014-12-09 16:36:27 +01:00
|
|
|
#!/bin/bash
|
|
|
|
export POSTGRES_PASSWORD="uleash"
|
|
|
|
|
2014-12-15 07:16:48 +01:00
|
|
|
echo "starting postgres in docker "
|
|
|
|
|
2021-01-19 09:43:19 +01:00
|
|
|
HASH=`docker run -P --name unleash-postgres -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -d postgres:10`
|
2014-12-15 09:25:31 +01:00
|
|
|
export PGPORT=`docker ps| grep unleash-post| awk '{print $(NF-1)}'| awk -F "->" '{print $1}'| awk -F \: '{print $2}'`
|
|
|
|
echo "PGPORT: $PGPORT"
|
|
|
|
echo ""
|
2014-12-15 07:16:48 +01:00
|
|
|
# ----------- Wait for postgres to start -----------
|
|
|
|
if [ -z "$DOCKER_HOST" ]
|
|
|
|
then
|
|
|
|
export database_host="127.0.0.1"
|
|
|
|
else
|
|
|
|
export database_host=$(echo $DOCKER_HOST |awk -F \/ '{print $NF}'| awk -F \: '{print $1}')
|
|
|
|
fi
|
2014-12-15 09:25:31 +01:00
|
|
|
for i in `seq 1 120`;
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
sleep 1
|
|
|
|
netcat -z $database_host $PGPORT && echo "postgres is up and running in docker in $i seconds!" && break
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2016-11-07 14:44:19 +01:00
|
|
|
export TEST_DATABASE_URL=postgres://postgres:$POSTGRES_PASSWORD@$database_host:$PGPORT/postgres
|
2014-12-15 07:16:48 +01:00
|
|
|
|
2017-08-23 11:23:07 +02:00
|
|
|
yarn
|
2021-01-19 09:43:19 +01:00
|
|
|
DATABASE_URL=$TEST_DATABASE_URL npm run db-migrate -- up
|
2017-08-23 11:23:07 +02:00
|
|
|
yarn test
|
2014-12-09 16:36:27 +01:00
|
|
|
docker stop $HASH
|
|
|
|
docker rm $HASH
|