fix: require DATABASE_URL in test.sh instead of provisioning Postgres

Spinning up a throwaway Postgres via Docker in test.sh forced Docker
onto every local dev machine — that's the job of the dedicated test
system, not local iteration. test.sh now fails loudly if DATABASE_URL
is unset instead, so the append-only guarantee still can't be silently
skipped on the release path, without assuming Docker locally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
noroot
2026-08-27 00:51:31 +02:00
parent e9e386df85
commit 667343fa81

View File

@@ -19,31 +19,12 @@ cd "$REPO_DIR"
# Append-only-Garantie auf finding/extraction/evidence_package). Ohne
# DATABASE_URL überspringt Go diese Tests still — das darf im
# Release-Pfad (release.sh ruft dieses Skript auf) nicht passieren.
# Deshalb hier immer ein Wegwerf-Postgres hochziehen.
PG_CONTAINER="deklarix-test-pg-$$"
PG_PORT=15432
command -v docker >/dev/null 2>&1 || fail "docker wird für die Store-Tests (Postgres) benötigt"
stop_test_db() { docker rm -f "$PG_CONTAINER" >/dev/null 2>&1 || true; }
trap stop_test_db EXIT
log "Starte Test-Postgres ($PG_CONTAINER) ..."
docker run -d --name "$PG_CONTAINER" \
-e POSTGRES_PASSWORD=test -e POSTGRES_DB=deklarix \
-p "${PG_PORT}:5432" postgres:16-alpine >/dev/null
ready=0
for _ in $(seq 1 30); do
if docker exec "$PG_CONTAINER" pg_isready -U postgres >/dev/null 2>&1; then
ready=1
break
fi
sleep 1
done
[[ "$ready" -eq 1 ]] || fail "Test-Postgres wurde nicht rechtzeitig bereit"
export DATABASE_URL="postgres://postgres:test@localhost:${PG_PORT}/deklarix?sslmode=disable"
# Postgres wird hier bewusst NICHT selbst hochgezogen — das ist Aufgabe
# des Testsystems, nicht des lokalen Dev-Rechners. DATABASE_URL muss dort
# vorkonfiguriert sein.
if [[ -z "${DATABASE_URL:-}" ]]; then
fail "DATABASE_URL ist nicht gesetzt — Store-Integrationstests (Append-only-Garantie) würden sonst still übersprungen. Auf dem Testsystem konfigurieren; für schnelle lokale Iteration ohne Postgres stattdessen gezielt 'go test ./internal/...' o. Ä. nutzen."
fi
log "go vet ..."
go vet ./... || fail "go vet fehlgeschlagen"