add database connection to backend
This commit is contained in:
@ -1,11 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
POSTGRES_URL=${POSTGRES_URL:-"postgresql://postgres:postgres@localhost:5432"}
|
||||
|
||||
if ! command -v cargo-nextest > /dev/null 2>&1; then
|
||||
echo "Command not found cargo-nextest"
|
||||
echo "Try installing with cargo install cargo-nextest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
psql "$POSTGRES_URL" -f ./scripts/create_test_db.sql
|
||||
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "Unable to connect to database, make sure it is started"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d logs ]; then
|
||||
mkdir logs
|
||||
fi
|
||||
@ -14,7 +24,7 @@ fi
|
||||
curl -s -X POST localhost:7001/admin/shutdown 2>&1 > /dev/null
|
||||
|
||||
# start server
|
||||
cargo run -- --port 7001 2>&1 > logs/nuchat.log &
|
||||
cargo run -- --port 7001 --postgres-url "$POSTGRES_URL" 2>&1 > logs/nuchat.log &
|
||||
|
||||
# run tests
|
||||
cargo nextest run --color=always 2>&1 | tee logs/test-output.log
|
||||
|
||||
Reference in New Issue
Block a user