Make testing easier with docker

This commit is contained in:
Kate Döen 2021-07-13 11:13:13 +02:00
parent 01acaf2eda
commit 8605fc7117
No known key found for this signature in database
GPG Key ID: 9B7155BC4AF02000
2 changed files with 13 additions and 1 deletions

View File

@ -6,7 +6,11 @@ tmessy = -svv
targs = --cov-report term-missing --cov migra
test:
$(tcommand) $(tmessy) $(targs) tests
docker build -t migra-postgres --build-arg LOCAL_USER=$$USER - < tests/Dockerfile
$(eval ID := $(shell docker run -d -p 5432:5432 migra-postgres))
$(tcommand) $(tmessy) $(targs) tests || true
docker stop $(ID)
docker rm $(ID)
stest:
$(tcommand) $(tmessy) $(targs) tests

8
tests/Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM postgres:13-alpine
ENV POSTGRES_HOST_AUTH_METHOD=trust
ENV POSTGRES_USER=postgres
ARG LOCAL_USER
RUN printf "psql --username ${POSTGRES_USER} --command=\"CREATE USER ${LOCAL_USER} CREATEDB CREATEROLE;\"" > /docker-entrypoint-initdb.d/10-create-users.sh
RUN printf "psql --username ${POSTGRES_USER} --command=\"CREATE DATABASE ${LOCAL_USER};\"" > /docker-entrypoint-initdb.d/20-create-database.sh