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>
This commit is contained in:
21
backend/internal/api/postgres_test_helpers_test.go
Normal file
21
backend/internal/api/postgres_test_helpers_test.go
Normal file
@ -0,0 +1,21 @@
|
||||
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 ""
|
||||
}
|
||||
Reference in New Issue
Block a user