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
go build goatherd.go
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
sh test_pam_goatherd.sh
......
......@@ -4,17 +4,21 @@ set -eu
go test -c -o ./goatherd.test &
PGHOST="$PWD/postgres_test"
if [ $# -ge 1 ]; then
PGHOST="$(realpath -- "$1")"
shift
fi
export PGHOST="$PGHOST"
if [ "${1:-x}" = "--start-pg" ]; then
PGHOST="$PWD/postgres_test"
if [ $# -ge 1 ]; then
PGHOST="$(realpath -- "$1")"
shift
fi
export PGHOST="$PGHOST"
. ./start_pg.sh
trap 'start_pg_cleanup' EXIT INT
. ./start_pg.sh
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
wait %1
......@@ -22,13 +26,13 @@ wait %1
echo
echo ===== Go Tests =====
DB_URL="host=$PGHOST dbname=goatherd_test" ./goatherd.test "$@"
./goatherd.test "$@"
echo ===== Command-Line Tests =====
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() {
......
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