Allow passing URI with database to tests (#942)

This commit is contained in:
daurnimator
2017-08-23 19:42:05 -05:00
committed by Joe Nelson
parent 9b5ce3a8af
commit adb3f5c8c0
2 changed files with 5 additions and 4 deletions
+4 -2
View File
@@ -17,8 +17,7 @@ then
fi
BASEPATH=$( cd $(dirname $0) ; pwd -P )
#Remove database path from the connection uri--prevents setting up the new database name with PGDATABASE
URI=$(echo $1 | cut -d'/' -f1-3)
URI="$1"
#Extract host and port--we need this to form the new connection string
HOST_PORT=$(echo $URI | cut -d'/' -f3 | cut -d'@' -f2 )
DB=$2
@@ -49,6 +48,9 @@ CREATE DATABASE $DB OWNER $TEST_USER_NAME;
ALTER SCHEMA public OWNER TO $TEST_USER_NAME;
EOF
#Remove database path from the connection uri--prevents setting up the new database name with PGDATABASE
URI=$(echo $URI | cut -d'/' -f1-3)
PGDATABASE=$DB PGOPTIONS='-c client_min_messages=WARNING' psql "$URI" --set=db=$DB -Xq <<EOF
CREATE EXTENSION IF NOT EXISTS pgcrypto;
ALTER DATABASE ${DB} SET request.jwt.claim.id = '-1';
+1 -2
View File
@@ -17,8 +17,7 @@ then
fi
BASEPATH=$( cd $(dirname $0) ; pwd -P )
#Remove database path from the connection uri
URI=$(echo $1 | cut -d'/' -f1-3)
URI="$1"
DB=$2
PGOPTIONS='-c client_min_messages=WARNING' psql "$URI" -Xq >/dev/null -c 'select rolcreatedb from pg_authid where rolname = current_user;' 2>/dev/null