Fix NewTestCluster to skip tests when DB is unreachable
All checks were successful
CI / test (push) Successful in 30s
All checks were successful
CI / test (push) Successful in 30s
pgxpool.NewWithConfig does not connect eagerly, so NewCluster succeeds even without a running database. Added a Ping check after cluster creation to reliably skip tests when the database cannot be reached. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,11 @@ func NewTestCluster(t testing.TB, opts ...dbx.Option) *dbx.Cluster {
|
||||
t.Skipf("dbxtest: cannot connect to test database: %v", err)
|
||||
}
|
||||
|
||||
if err := cluster.Ping(ctx); err != nil {
|
||||
cluster.Close()
|
||||
t.Skipf("dbxtest: cannot reach test database: %v", err)
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
cluster.Close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user