#!/usr/bin/env bash # pgTAP-Tests gegen den laufenden Supabase-Stack ausführen, wenn der Docker-Daemon remote ist # (DOCKER_HOST=tcp://..., z. B. dind). `supabase test db` bindet supabase/tests per Host-Pfad ein; # dieser Pfad existiert im dind nicht (Ergebnis: "no pgTAP tests found"). Daher: Tests per # `docker cp` in einen pg_prove-Container kopieren. Voraussetzung: `supabase start` lief. set -euo pipefail PROJECT_ID="${SUPABASE_PROJECT_ID:-shuffle}" # = project_id in supabase/config.toml PG_PROVE_IMAGE="${PG_PROVE_IMAGE:-public.ecr.aws/supabase/pg_prove:3.36}" # wie in Supabase CLI 3.0.0 # pgTAP wie `supabase test db` vorab aktivieren (die Tests rufen nur plan() etc. auf) docker exec "supabase_db_${PROJECT_ID}" psql -U postgres -d postgres -v ON_ERROR_STOP=1 \ -c "create extension if not exists pgtap with schema extensions" cid=$(docker create --network "supabase_network_${PROJECT_ID}" -e PGPASSWORD=postgres \ "$PG_PROVE_IMAGE" pg_prove --ext .sql -r -h "supabase_db_${PROJECT_ID}" -U postgres -d postgres /tests) trap 'docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT docker cp supabase/tests "$cid:/" docker start -a "$cid"