fix(test): gracefully skip DB tests when database is unreachable
pgxpool.New is lazy and doesn't connect immediately. Add pool.Ping() after creation so CI environments without PostgreSQL skip cleanly instead of failing with os.Exit(1). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
04997b4011
commit
a5aedf5dfe
2 changed files with 10 additions and 0 deletions
|
|
@ -41,6 +41,11 @@ func TestMain(m *testing.M) {
|
|||
fmt.Printf("Skipping tests: could not connect to database: %v\n", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
if err := pool.Ping(ctx); err != nil {
|
||||
fmt.Printf("Skipping tests: database not reachable: %v\n", err)
|
||||
pool.Close()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
queries := db.New(pool)
|
||||
hub := realtime.NewHub()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue