wip: mysql driver

add tests for pg driver and mysql driver (in progress)
This commit is contained in:
2024-07-11 11:20:36 +02:00
parent 711c426898
commit 024eb61a41
12 changed files with 1027 additions and 38 deletions

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# Start Docker containers
docker-compose up -d
# Wait for PostgreSQL to be ready
until docker exec db-postgres-test pg_isready -U postgres; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done
# Wait for MySQL to be ready
until docker exec db-mysql-test mysqladmin ping -h "localhost" --silent; do
>&2 echo "MySQL is unavailable - sleeping"
sleep 1
done
# Set up PostgreSQL test data
docker exec -i db-postgres-test psql -U postgres <<EOF
CREATE TABLE IF NOT EXISTS test_table (id SERIAL PRIMARY KEY, name VARCHAR(50));
INSERT INTO test_table (name) VALUES ('John Doe');
EOF
# Set up MySQL test data
docker exec -i db-mysql-test mysql -uroot -pmysecretpassword<<EOF
CREATE DATABASE IF NOT EXISTS test_db;
USE test_db;
CREATE TABLE IF NOT EXISTS test_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50));
INSERT INTO test_table (name) VALUES ('Jane Doe');
EOF
echo "Test databases are ready"

View File

@@ -0,0 +1,16 @@
#!/bin/bash
# Clean up PostgreSQL test data
docker exec -i db-postgres-test psql -U postgres <<EOF
DROP TABLE IF EXISTS test_table;
EOF
# Clean up MySQL test data
docker exec -i db-mysql-test mysql -uroot -pmysecretpassword --database=test_db<<EOF
DROP TABLE IF EXISTS test_table;
EOF
# Stop and remove Docker containers and volumes
docker-compose down -v
echo "Test databases are cleaned up"