feat(sqltest): Make container port configurable
This commit is contained in:
2 files changed
+20
No files matched your search
@@ -6,6 +6,12 @@ CWD := $(shell pwd)
|
||||
PG_DOCKER_TAG ?= 13-alpine
|
||||
# Version of pg_tap docker image
|
||||
PG_TAP_DOCKER_TAG ?= pg13
|
||||
SQL_TEST_DB_PORT ?=
|
||||
DOCKER_ARGS ?=
|
||||
ifneq ($(strip $(SQL_TEST_DB_PORT)),)
|
||||
DOCKER_ARGS += -p $(SQL_TEST_DB_PORT):5432
|
||||
endif
|
||||
|
||||
|
||||
# Pass through options to pg_prove
|
||||
# See: https://pgtap.org/pg_prove.html
|
||||
@@ -32,6 +38,7 @@ test:
|
||||
@echo Using $(PG_TAP_DOCKER_IMAGE)
|
||||
@docker run -d \
|
||||
--name $(SQL_TEST_CONTAINER_NAME) \
|
||||
$(DOCKER_ARGS) \
|
||||
-e POSTGRES_PASSWORD=boundary \
|
||||
-e POSTGRES_USER=boundary \
|
||||
-e POSTGRES_DB=boundary \
|
||||
@@ -55,12 +62,16 @@ database-up:
|
||||
@echo Using $(POSTGRES_DOCKER_IMAGE)
|
||||
@docker run -d \
|
||||
--name $(SQL_TEST_CONTAINER_NAME) \
|
||||
$(DOCKER_ARGS) \
|
||||
-e POSTGRES_PASSWORD=boundary \
|
||||
-e POSTGRES_USER=boundary \
|
||||
-e POSTGRES_DB=boundary \
|
||||
-v "$(CWD)/../schema/migrations":/migrations \
|
||||
-v "$(CWD)/initdb.d":/docker-entrypoint-initdb.d/ \
|
||||
$(POSTGRES_DOCKER_IMAGE)
|
||||
ifdef SQL_TEST_DB_PORT
|
||||
@echo "Test database available at: postgres://boundary:boundary@localhost:$(SQL_TEST_DB_PORT)/boundary?sslmode=disable"
|
||||
endif
|
||||
|
||||
run-tests:
|
||||
@echo Using $(PG_TAP_DOCKER_IMAGE)
|
||||
|
||||
@@ -63,6 +63,15 @@ for available options, i.e:
|
||||
make PROVE_OPTS='-j9 -v'
|
||||
```
|
||||
|
||||
By default the database docker container does not use a host port.
|
||||
This can be changed using an environment variable:
|
||||
|
||||
```bash
|
||||
$ export SQL_TEST_DB_PORT=5433
|
||||
$ make database-up
|
||||
$ make run-tests
|
||||
```
|
||||
|
||||
Different versions of postgres can easily be tested:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in new issue
Block a user