0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:40:03 +01:00
posthog/bin/tests
Paul D'Ambra b2e1b16a31
Add slightly kinder database url defaults (#7730)
* Add DB user and pass to DB URL for DEBUG mode and to bin tests for dropping test database

* ensmallen the blast radius of the DB connection settings changes

* make PGPORT settable too

* set PG ENV variables in bin tests

* Revert "set PG ENV variables in bin tests"

This reverts commit 4991f28808.
2021-12-16 09:31:41 +00:00

33 lines
977 B
Bash
Executable File

#!/bin/bash
set -e
if ! command -v nodemon &> /dev/null
then
echo "Please install nodemon (npm install -g nodemon) to automatically run tests."
exit
fi
if [ $# -eq 0 ]; then
echo "Are you sure you want to run all backend tests? You can run specific tests by doing:"
echo " "
echo "bin/tests posthog/api/test/test_user.py::TestUserAPI::test_retrieve_current_user"
echo " "
read -r -p "Run all tests? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
echo "OK!"
else
exit
fi
fi
export REDIS_URL='redis:///'
PG_HOST="${PGHOST:=localhost}"
PG_USER="${PGUSER:=posthog}"
PG_PASSWORD="${PGPASSWORD:=posthog}"
PG_PORT="${PGPORT:=5432}"
psql posthog -d "postgres://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}" -c "drop database if exists test_posthog"
nodemon -w ./posthog -w ./ee --ext py --exec "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES pytest --reuse-db -s $* --snapshot-update; mypy posthog ee"