mirror of
https://github.com/ershisan99/db-studio.git
synced 2025-12-17 05:09:25 +00:00
wip: mysql driver
add tests for pg driver and mysql driver (in progress)
This commit is contained in:
32
api/scripts/setup-test-db.sh
Normal file
32
api/scripts/setup-test-db.sh
Normal 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"
|
||||
16
api/scripts/teardown-test-db.sh
Normal file
16
api/scripts/teardown-test-db.sh
Normal 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"
|
||||
Reference in New Issue
Block a user