2020-06-23 18:42:54 +02:00
|
|
|
#!/bin/bash
|
2021-02-24 08:32:44 +01:00
|
|
|
set -e
|
2020-06-23 18:42:54 +02:00
|
|
|
|
2020-11-26 15:32:38 +01:00
|
|
|
if ! command -v nodemon &> /dev/null
|
2020-11-18 20:53:01 +01:00
|
|
|
then
|
2022-12-12 10:28:06 +01:00
|
|
|
echo "Please install nodemon (pnpm install -g nodemon) to automatically run tests."
|
2020-11-18 20:53:01 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-05-04 15:41:22 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-02-24 08:32:44 +01:00
|
|
|
export REDIS_URL='redis:///'
|
2021-12-16 10:31:41 +01:00
|
|
|
|
|
|
|
PG_HOST="${PGHOST:=localhost}"
|
|
|
|
PG_USER="${PGUSER:=posthog}"
|
|
|
|
PG_PASSWORD="${PGPASSWORD:=posthog}"
|
|
|
|
PG_PORT="${PGPORT:=5432}"
|
2022-04-15 12:43:05 +02:00
|
|
|
PGOPTIONS='--client-min-messages=warning' psql posthog -d "postgres://${PG_USER}:${PG_PASSWORD}@${PG_HOST}:${PG_PORT}" -c "drop database if exists test_posthog" 1> /dev/null
|
|
|
|
|
2024-01-10 09:32:55 +01:00
|
|
|
nodemon -w ./posthog -w ./ee --ext py --exec "OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES pytest --reuse-db --durations-min=2.0 ${MIGRATIONS} -s $* --snapshot-update; mypy -p posthog | mypy-baseline filter"
|