#!/usr/bin/env bash # Spin up Postgres + MySQL, run the live DB integration tests, tear down. # Requires Docker. From the repo root: bun run test:db:live set -euo pipefail cd "$(dirname "$0")/.." COMPOSE="docker compose -f docker-compose.yml" cleanup() { $COMPOSE down -v >/dev/null 2>&1 || true; } trap cleanup EXIT echo "Starting Postgres + MySQL…" $COMPOSE up -d echo "Waiting for databases to become healthy…" for _ in $(seq 1 60); do pg=$(docker inspect --format '{{.State.Health.Status}}' "$($COMPOSE ps -q postgres)" 2>/dev/null || echo starting) my=$(docker inspect --format '{{.State.Health.Status}}' "$($COMPOSE ps -q mysql)" 2>/dev/null || echo starting) [ "$pg" = healthy ] && [ "$my" = healthy ] && break sleep 2 done export WRNEXUS_PG_URL="postgres://wrn:wrn@localhost:5433/wrn_test" export WRNEXUS_MYSQL_URL="mysql://wrn:wrn@localhost:3307/wrn_test" echo "Running live DB tests…" bun test packages/db/test/live-db.test.ts