fooder-api/test.sh

41 lines
772 B
Bash
Raw Normal View History

#!/bin/bash
#
# Run fooder api tests
#
echo "Running fooder api tests"
# if exists, remove test.db
[ -f test.db ] && rm test.db
# create test env values
export DB_URI="sqlite+aiosqlite:///test.db"
export ECHO_SQL=0
export SECRET_KEY=$(openssl rand -hex 32)
export REFRESH_SECRET_KEY=$(openssl rand -hex 32)
export API_KEY=$(openssl rand -hex 32)
python -m fooder --create-tables
# finally run tests
if [[ $# -eq 1 ]]; then
python -m pytest fooder --disable-warnings -sv -k "${1}"
else
python -m pytest fooder --disable-warnings -sv
fi
2024-05-20 12:20:30 +02:00
status=$?
# unset test env values
unset POSTGRES_USER
unset POSTGRES_DATABASE
unset POSTGRES_PASSWORD
unset SECRET_KEY
unset REFRESH_SECRET
unset API_KEY
# if exists, remove test.db
[ -f test.db ] && rm test.db
2024-05-20 12:20:30 +02:00
exit $status