2026-02-02 18:34:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
2026-04-02 17:42:03 +00:00
|
|
|
# CONTRACT: GOMAXPROCS=1 (Frugality Manifesto)
|
|
|
|
|
COVERAGE_THRESHOLD=60
|
|
|
|
|
|
2026-02-02 18:34:14 +00:00
|
|
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
|
BACKEND_DIR="$REPO_ROOT/veza-backend-api"
|
|
|
|
|
|
2026-04-02 17:42:03 +00:00
|
|
|
echo "Backend Unit Tests (Low Power Mode)"
|
2026-02-02 18:34:14 +00:00
|
|
|
|
|
|
|
|
cd "$BACKEND_DIR"
|
|
|
|
|
|
|
|
|
|
export GOMAXPROCS=1
|
2026-04-02 17:42:03 +00:00
|
|
|
echo "Constraint: GOMAXPROCS=1"
|
|
|
|
|
|
|
|
|
|
echo "Running Unit Tests with coverage..."
|
|
|
|
|
go test ./internal/handlers/... ./internal/services/... -short -coverprofile=coverage.out -covermode=atomic
|
|
|
|
|
|
|
|
|
|
COVERAGE=$(go tool cover -func=coverage.out | tail -1 | awk '{print $3}' | tr -d '%')
|
|
|
|
|
echo "Coverage: ${COVERAGE}%"
|
2026-02-02 18:34:14 +00:00
|
|
|
|
2026-04-02 17:42:03 +00:00
|
|
|
if awk -v c="$COVERAGE" -v t="$COVERAGE_THRESHOLD" 'BEGIN {exit !(c+0>=t)}'; then
|
|
|
|
|
echo "Coverage gate passed (>= ${COVERAGE_THRESHOLD}%)"
|
|
|
|
|
else
|
|
|
|
|
echo "FATAL: Coverage ${COVERAGE}% is below threshold ${COVERAGE_THRESHOLD}%"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-02-02 18:34:14 +00:00
|
|
|
|
2026-04-02 17:42:03 +00:00
|
|
|
echo "Unit tests passed."
|