-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathrun_tests.sh
executable file
·28 lines (24 loc) · 1.14 KB
/
run_tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -e
for db_type in mysql postgres sqlite; do
for database in domain_db_test_domains domain_db_test_email domain_db_test_pdns domain_db_test_routes; do
if [ "${db_type}" = "mysql" ]; then
db_path="mysql://root:[email protected]/${database}"
mysql -u root -p root -h 127.0.0.1 -P 3306 -e "drop database ${database}" >/dev/null 2>&1 || true
elif [ "${db_type}" = "postgres" ]; then
db_path="postgres://postgres:[email protected]/${database}"
PGPASSWORD=password dropdb -U postgres -h 127.0.0.1 -p 5432 "${database}" >/dev/null 2>&1 || true
elif [ "${db_type}" = "sqlite" ]; then
db_path="./${database}.sqlite"
rm -f "${db_path}" >/dev/null 2>&1 || true
else
echo "Database type is invalid, must be: mysql/postgres/sqlite"
exit 1
fi
diesel --database-url "${db_path}" setup --migration-dir "migrations/${db_type}"
diesel --database-url "${db_path}" migration --migration-dir "migrations/${db_type}" run
done
echo
echo "Testing ${db_type}"
cargo test --features "${db_type}" "$@"
done