Add a check-with-tmp-database target

This is aimed at testing using pg_tmp, to create a temporary test
database (and instance of PostgreSQL). This is both useful for testing all the
migrations, but should also be useful for running the tests within the guix
package.
This commit is contained in:
Christopher Baines 2019-10-08 19:45:59 +01:00
parent 356a5954b2
commit c40747a5ee

View file

@ -49,6 +49,14 @@ install-data-hook:
# :( # :(
rm -r "$(DESTDIR)$(moddir)/tests" rm -r "$(DESTDIR)$(moddir)/tests"
check-with-tmp-database:
$(eval URI := $(shell pg_tmp))
$(eval GUIX_DATA_SERVICE_DATABASE_URI := $(patsubst postgresql:///test%,postgresql://guix_data_service@localhost/guix_data_service_test%,$(URI)))
psql "$(URI)" --command="CREATE USER guix_data_service"
psql "$(URI)" --command="CREATE DATABASE guix_data_service_test WITH OWNER guix_data_service"
sqitch deploy --target="$(GUIX_DATA_SERVICE_DATABASE_URI)"
GUIX_DATA_SERVICE_DATABASE_URI="$(GUIX_DATA_SERVICE_DATABASE_URI)" make check
SOURCES = \ SOURCES = \
guix-data-service/branch-updated-emails.scm \ guix-data-service/branch-updated-emails.scm \
guix-data-service/builds.scm \ guix-data-service/builds.scm \