1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

test: address pr comments

This commit is contained in:
Steven Tang 2022-12-27 20:37:53 +11:00
parent 03af194385
commit 497046d0a4
No known key found for this signature in database
GPG Key ID: 1597520C734BAE66
4 changed files with 19 additions and 10 deletions

View File

@ -21,7 +21,7 @@ app:
db: db:
host: 127.0.0.1 host: 127.0.0.1
port: 3306 port: 53306
user: wakapi user: wakapi
password: wakapi password: wakapi
name: wakapi name: wakapi

View File

@ -21,7 +21,7 @@ app:
db: db:
host: 127.0.0.1 host: 127.0.0.1
port: 5432 port: 55432
user: wakapi user: wakapi
password: wakapi password: wakapi
name: wakapi name: wakapi

View File

@ -7,6 +7,7 @@ services:
POSTGRES_USER: "wakapi" POSTGRES_USER: "wakapi"
POSTGRES_PASSWORD: "wakapi" POSTGRES_PASSWORD: "wakapi"
POSTGRES_DB: "wakapi" POSTGRES_DB: "wakapi"
PGPORT: 55432
network_mode: host network_mode: host
volumes: volumes:
- wakapi-postgres:/var/lib/postgresql/data - wakapi-postgres:/var/lib/postgresql/data
@ -14,6 +15,7 @@ services:
mysql: mysql:
image: mysql:8 image: mysql:8
environment: environment:
MYSQL_TCP_PORT: 53306
MYSQL_USER: "wakapi" MYSQL_USER: "wakapi"
MYSQL_PASSWORD: "wakapi" MYSQL_PASSWORD: "wakapi"
MYSQL_DATABASE: "wakapi" MYSQL_DATABASE: "wakapi"
@ -25,6 +27,7 @@ services:
mariadb: mariadb:
image: mariadb:10 image: mariadb:10
environment: environment:
MYSQL_TCP_PORT: 53306
MARIADB_USER: "wakapi" MARIADB_USER: "wakapi"
MARIADB_PASSWORD: "wakapi" MARIADB_PASSWORD: "wakapi"
MARIADB_DATABASE: "wakapi" MARIADB_DATABASE: "wakapi"

View File

@ -34,14 +34,24 @@ if [[ $MIGRATION -eq 1 ]]; then
echo "Running tests with release version" echo "Running tests with release version"
fi fi
cleanup() {
if [ -n "$pid" ] && ps -p "$pid" > /dev/null; then
kill -TERM "$pid"
fi
if [ "${docker_down-0}" -eq 1 ]; then
docker-compose -f "$script_dir/docker-compose.yml" down
fi
}
trap cleanup EXIT
# Initialise test data # Initialise test data
case $1 in case $1 in
postgres|mysql|mariadb) postgres|mysql|mariadb)
docker compose -f "$script_dir/docker-compose.yml" down docker-compose -f "$script_dir/docker-compose.yml" down
docker volume rm "testing_wakapi-$1" docker volume rm "testing_wakapi-$1"
docker_down=1 docker_down=1
docker compose -f "$script_dir/docker-compose.yml" up --wait -d "$1" docker-compose -f "$script_dir/docker-compose.yml" up --wait -d "$1"
if [ "$1" == "mariadb" ]; then if [ "$1" == "mariadb" ]; then
config="config.mysql.yml" config="config.mysql.yml"
else else
@ -50,9 +60,9 @@ case $1 in
db_port=0 db_port=0
if [ "$1" == "postgres" ]; then if [ "$1" == "postgres" ]; then
db_port=5432 db_port=55432
else else
db_port=3306 db_port=53306
fi fi
for _ in $(seq 0 30); do for _ in $(seq 0 30); do
@ -122,9 +132,5 @@ if [[ $MIGRATION -eq 1 ]]; then
kill -TERM $pid kill -TERM $pid
fi fi
if [ "$docker_down" -eq 1 ]; then
docker compose -f "$script_dir/docker-compose.yml" down
fi
echo "Exiting with status $exit_code" echo "Exiting with status $exit_code"
exit $exit_code exit $exit_code