Skip to content

Commit

Permalink
more test docker cleanup. ver bump to 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michelp committed Dec 24, 2018
1 parent a47d702 commit 0f1aa16
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM postgres:11
RUN apt-get update && apt-get install -y make git postgresql-server-dev-11 postgresql-11-pgtap
RUN git clone https://github.com/michelp/pgjwt.git
RUN mkdir "/pgjwt"
WORKDIR "/pgjwt"
COPY . .
RUN make && make install
COPY test.sql test.sql

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
EXTENSION = pgjwt
DATA = pgjwt--0.0.1.sql
DATA = pgjwt--0.1.0.sql

# postgres build stuff
PG_CONFIG = pg_config
Expand Down
20 changes: 11 additions & 9 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
#!/bin/bash

set -e

DB_HOST="pgjwt-test-db"
DB_NAME="postgres"

POSTGRES_SU="postgres"

SU="postgres"
EXEC="docker exec $DB_HOST"

echo destroying any previous test container
docker rm --force "$DB_HOST"

echo building test image
docker build test --force-rm -t pgjwt/test
docker build . --force-rm -t pgjwt/test

echo running test container
docker run -d --name "$DB_HOST" pgjwt/test

echo waiting for database to accept connections
until
$EXEC \
psql -o /dev/null -t -q -U "$POSTGRES_SU" \
psql -o /dev/null -t -q -U "$SU" \
-c 'select pg_sleep(1)' \
2>/dev/null;
do sleep 1;
done

echo running tests
$EXEC pg_prove -U "$POSTGRES_SU" /pgjwt/test.sql
$EXEC pg_prove -U "$SU" /pgjwt/test.sql

echo destroying test container and image
docker rm --force "$DB_HOST"
docker rmi pgjwt/test
File renamed without changes.

0 comments on commit 0f1aa16

Please sign in to comment.