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>
39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Deklarix — Test-Skript
|
|
#
|
|
# Führt alle Go-Tests aus + Vet + Build-Check.
|
|
# Wird auch im CI/vor jedem Release ausgeführt.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
|
|
GRN='\033[0;32m'; RED='\033[0;31m'; NC='\033[0m'
|
|
log() { echo -e "${GRN}[test]${NC} $*"; }
|
|
fail() { echo -e "${RED}[FAIL]${NC} $*"; exit 1; }
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
# internal/store hat Integrationstests gegen echtes Postgres (u. a. die
|
|
# 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.
|
|
# 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"
|
|
|
|
log "go test ./... "
|
|
go test -race -count=1 ./... || fail "Tests fehlgeschlagen"
|
|
|
|
log "Build-Check (amd64) ..."
|
|
GOARCH=amd64 GOOS=linux go build -o /dev/null ./cmd/deklarix/ || fail "Build fehlgeschlagen"
|
|
|
|
log "Alle Tests bestanden ✓"
|