Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make testing easier with docker #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -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