Skip to content

Commit 33a2a62

Browse files
committed
Add pgtag to Dokerfile
To allow testing against different versions of Postgres.
1 parent 3c93cd2 commit 33a2a62

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

doc/pgtap.mmd

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,29 @@ You can use it to run the test suite as a database super user like so:
152152

153153
make test PGUSER=postgres
154154

155-
To run the tests in a local docker environment for development, run:
155+
To run the tests in a local docker environment using the latest version
156+
of PostgreSQL, run:
156157

157158
cd test
158-
docker-compose build test
159+
docker compose build test
159160
# start the postgres server in a docker container in the background
160-
docker-compose up -d test
161+
docker compose up -d test
161162
# run the regression tests
162-
docker-compose exec test make install installcheck
163-
# run the tests with pg_proove
163+
docker compose exec test make install installcheck
164+
# run the tests with pg_prove
164165
# "run" builds and installs pgTAP, runs "CREATE EXTENSION"
165166
# and then runs make test
166-
docker-compose exec test run
167+
docker compose exec test run
168+
# Shut down the postgres container
169+
docker compose down
170+
171+
To test with a different version of PostgreSQL, set the environment variable
172+
`$pgtag` to one of the [PostgreSQL Docker](https://hub.docker.com/_/postgres)
173+
tags:
174+
175+
export pgtag=12-alpine
176+
177+
Then run the above commands.
167178

168179
Adding pgTAP to a Database
169180
--------------------------

test/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
FROM postgres:13.0-alpine
1+
ARG pgtag
2+
FROM postgres:${pgtag:-alpine}
23
ENV POSTGRES_HOST_AUTH_METHOD trust
34

45
RUN apk --no-cache add make perl-dev patch \
5-
&& cpan TAP::Parser::SourceHandler::pgTAP
6+
&& cpan -T TAP::Parser::SourceHandler::pgTAP
67
ENV PGUSER postgres
78

89
WORKDIR /pgtap

test/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ version: "3"
22

33
services:
44
test:
5-
build: .
5+
build:
6+
context: .
7+
args: [pgtag]
68
volumes:
79
- ../:/pgtap
810
- postgres:/var/lib/postgresql/data

0 commit comments

Comments
 (0)