2023-09-03 15:43:24 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Run fooder api tests
|
|
|
|
#
|
|
|
|
|
|
|
|
echo "Running fooder api tests"
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
# if exists, remove test.db
|
|
|
|
[ -f test.db ] && rm test.db
|
2023-09-03 15:43:24 +02:00
|
|
|
|
|
|
|
# create test env values
|
2024-05-20 12:10:17 +02:00
|
|
|
export DB_URI="sqlite+aiosqlite:///test.db"
|
|
|
|
export ECHO_SQL=0
|
2023-09-03 15:43:24 +02:00
|
|
|
export SECRET_KEY=$(openssl rand -hex 32)
|
2024-05-20 12:10:17 +02:00
|
|
|
export REFRESH_SECRET_KEY=$(openssl rand -hex 32)
|
2024-05-21 11:11:47 +02:00
|
|
|
export API_KEY=$(openssl rand -hex 32)
|
2023-09-03 15:43:24 +02:00
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
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
|
2023-09-03 15:43:24 +02:00
|
|
|
|
2024-05-20 12:20:30 +02:00
|
|
|
status=$?
|
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
# unset test env values
|
2023-09-03 15:43:24 +02:00
|
|
|
unset POSTGRES_USER
|
|
|
|
unset POSTGRES_DATABASE
|
|
|
|
unset POSTGRES_PASSWORD
|
|
|
|
unset SECRET_KEY
|
|
|
|
unset REFRESH_SECRET
|
2024-05-21 11:11:47 +02:00
|
|
|
unset API_KEY
|
2023-09-03 15:43:24 +02:00
|
|
|
|
2024-05-20 12:10:17 +02:00
|
|
|
# if exists, remove test.db
|
|
|
|
[ -f test.db ] && rm test.db
|
2024-05-20 12:20:30 +02:00
|
|
|
|
|
|
|
exit $status
|