Files
TradarrV2/backend/internal/api/postgres_test_helpers_test.go
Blomios 9970b49746 test(infra): add postgres and frontend test tooling
Add repeatable PostgreSQL integration tests and configure Vitest, Testing Library, and ESLint.

Refs #11

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-20 19:54:28 +01:00

22 lines
561 B
Go

package api_test
import (
"os"
"testing"
)
// postgresTestURL allows ordinary unit-test runs to skip integration cases,
// while making an explicitly requested PostgreSQL run fail if its harness did
// not provide a database URL.
func postgresTestURL(t *testing.T) string {
t.Helper()
if dsn := os.Getenv("TEST_DATABASE_URL"); dsn != "" {
return dsn
}
if os.Getenv("TEST_DATABASE_REQUIRED") == "1" {
t.Fatal("TEST_DATABASE_REQUIRED=1 but TEST_DATABASE_URL is empty")
}
t.Skip("TEST_DATABASE_URL absent: isolated PostgreSQL required")
return ""
}