Add repeatable PostgreSQL integration tests and configure Vitest, Testing Library, and ESLint. Refs #11 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
561 B
Go
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 ""
|
|
}
|