From c40747a5ee3fd1f3606d2b9d99b4be7b5ef506c7 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 8 Oct 2019 19:45:59 +0100 Subject: [PATCH] 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. --- Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile.am b/Makefile.am index 43c6c2e..a09627b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,6 +49,14 @@ install-data-hook: # :( 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 = \ guix-data-service/branch-updated-emails.scm \ guix-data-service/builds.scm \