Skip to content
Snippets Groups Projects
Commit 497b3b57 authored by Lukas Braun's avatar Lukas Braun
Browse files

Only start Postgres for tests when requested

parent b276bd54
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ goatherd: goatherd.go ...@@ -8,7 +8,7 @@ goatherd: goatherd.go
go build goatherd.go go build goatherd.go
test_pg: goatherd.go goatherd_test.go test_pg.sh goatherd test_pg: goatherd.go goatherd_test.go test_pg.sh goatherd
sh test_pg.sh sh test_pg.sh --start-pg
test_pam_goatherd: goatherd pam_goatherd.so test_pam_goatherd.sh test_pam_goatherd: goatherd pam_goatherd.so test_pam_goatherd.sh
sh test_pam_goatherd.sh sh test_pam_goatherd.sh
......
...@@ -4,17 +4,21 @@ set -eu ...@@ -4,17 +4,21 @@ set -eu
go test -c -o ./goatherd.test & go test -c -o ./goatherd.test &
PGHOST="$PWD/postgres_test" if [ "${1:-x}" = "--start-pg" ]; then
if [ $# -ge 1 ]; then PGHOST="$PWD/postgres_test"
PGHOST="$(realpath -- "$1")" if [ $# -ge 1 ]; then
shift PGHOST="$(realpath -- "$1")"
fi shift
export PGHOST="$PGHOST" fi
export PGHOST="$PGHOST"
. ./start_pg.sh . ./start_pg.sh
trap 'start_pg_cleanup' EXIT INT trap 'start_pg_cleanup' EXIT INT
createdb goatherd_test createdb goatherd_test
export DB_URL="host=$PGHOST dbname=goatherd_test"
fi
echo Waiting for compile to finish echo Waiting for compile to finish
wait %1 wait %1
...@@ -22,13 +26,13 @@ wait %1 ...@@ -22,13 +26,13 @@ wait %1
echo echo
echo ===== Go Tests ===== echo ===== Go Tests =====
DB_URL="host=$PGHOST dbname=goatherd_test" ./goatherd.test "$@" ./goatherd.test "$@"
echo ===== Command-Line Tests ===== echo ===== Command-Line Tests =====
gh() { gh() {
./goatherd -config "$PWD/pam_goatherd_test.conf" -db-url "host=$PGHOST dbname=goatherd_test" "$@" ./goatherd -config "$PWD/pam_goatherd_test.conf" -db-url "$DB_URL" "$@"
} }
expecting() { expecting() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment