From e2c75048083dc52aa1b95a9d55f9fc351556d0c9 Mon Sep 17 00:00:00 2001
From: Lukas Braun <koomi@moshbit.net>
Date: Sat, 7 Oct 2017 22:51:27 +0200
Subject: [PATCH] Only start PG for tests if $DB_URL is not in env

---
 Makefile             | 4 ++--
 test_pam_goatherd.sh | 2 +-
 test_pg.sh           | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 299b6e9..3a1ecb6 100644
--- a/Makefile
+++ b/Makefile
@@ -8,10 +8,10 @@ goatherd: goatherd.go
 	go build goatherd.go
 
 test_pg: goatherd.go goatherd_test.go test_pg.sh goatherd
-	sh test_pg.sh --start-pg
+	sh test_pg.sh
 
 test_pam_goatherd: goatherd pam_goatherd.so test_pam_goatherd.sh
-	sh test_pam_goatherd.sh --start-pg
+	sh test_pam_goatherd.sh
 
 test: test_pg test_pam_goatherd
 
diff --git a/test_pam_goatherd.sh b/test_pam_goatherd.sh
index 468ea7b..0550324 100644
--- a/test_pam_goatherd.sh
+++ b/test_pam_goatherd.sh
@@ -4,7 +4,7 @@ set -eu
 
 PAMWRAPPER=/usr/lib/x86_64-linux-gnu/libpam_wrapper.so
 
-if [ "${1:-x}" = "--start-pg" ]; then
+if [ "${DB_URL:-x}" = "x" ]; then
     export PGHOST="$PWD/pg_pam_test"
     . ./start_pg.sh
     export DB_URL="host=$PGHOST"
diff --git a/test_pg.sh b/test_pg.sh
index 19bf202..008df83 100644
--- a/test_pg.sh
+++ b/test_pg.sh
@@ -4,8 +4,7 @@ set -eu
 
 go test -c -o ./goatherd.test &
 
-if [ "${1:-x}" = "--start-pg" ]; then
-    shift
+if [ "${DB_URL:-x}" = "x" ]; then
     PGHOST="$PWD/postgres_test"
     if [ $# -ge 1 ]; then
         PGHOST="$(realpath -- "$1")"
-- 
GitLab