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

Script testing with PostgreSQL

parent bc7f25aa
No related branches found
No related tags found
No related merge requests found
......@@ -3,10 +3,13 @@ CFLAGS += -std=c11 -D_POSIX_C_SOURCE=201112 -Wall -Wconversion -fPIC
goatherd: goatherd.go
go build goatherd.go
goatherd_test: goatherd.go goatherd_test.go
test_sqlite: goatherd.go goatherd_test.go
go test
test: goatherd_test
test_pg: goatherd.go goatherd_test.go test_pg.sh
sh test_pg.sh
test: test_sqlite test_pg
pam_goatherd.so: pam_goatherd.o
$(LINK.c) -lpam -lgnutls -Wl,-soname,$@ -shared $< -o $@
......
#!/bin/sh
set -eu
export PGHOST="$PWD/postgres_test"
if [ $# -ge 1 ]; then
PGHOST="$(realpath -- "$1")"
shift
fi
export PGDATA="$PGHOST/data"
cleanup() {
pg_ctl stop || true
echo -n "removing directories... "
rm -rf $PGHOST
echo "[x]"
}
trap 'cleanup' EXIT INT
mkdir -p "$PGHOST"
initdb
echo "unix_socket_directories = '$PGHOST'" >"$PGDATA/postgresql.conf"
pg_ctl -l "$PGHOST/log" -o '-h ""' start
export PGHOST="$PGHOST"
createdb goatherd_test
DB_DRIVER=postgres DB_URL="host=$PGHOST dbname=goatherd_test" go test "$@"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment