From 0f1aa16ef17084aa669999ac60f489236c0ed2bc Mon Sep 17 00:00:00 2001 From: Michel Pelletier Date: Mon, 24 Dec 2018 11:44:20 -0800 Subject: [PATCH] more test docker cleanup. ver bump to 0.1.0 --- test/Dockerfile => Dockerfile | 4 ++-- Makefile | 2 +- test.sh | 20 +++++++++++--------- test/test.sql => test.sql | 0 4 files changed, 14 insertions(+), 12 deletions(-) rename test/Dockerfile => Dockerfile (67%) rename test/test.sql => test.sql (100%) diff --git a/test/Dockerfile b/Dockerfile similarity index 67% rename from test/Dockerfile rename to Dockerfile index 96b67c9..1383063 100644 --- a/test/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index 04cb53d..b2e76d7 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/test.sh b/test.sh index cd9e197..1866200 100755 --- a/test.sh +++ b/test.sh @@ -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 diff --git a/test/test.sql b/test.sql similarity index 100% rename from test/test.sql rename to test.sql