Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(test): gracefully skip DB tests when database is unreachable

yushena5aedf5dfe0d
diff --git a/server/cmd/server/integration_test.go b/server/cmd/server/integration_test.go
index a879d3c198..a0cee2f3d4 100644
--- a/server/cmd/server/integration_test.go
+++ b/server/cmd/server/integration_test.go
@@ -49,6 +49,11 @@ func TestMain(m *testing.M) {
fmt.Printf("Skipping integration tests: could not connect to database: %v\n", err)
os.Exit(0)
}
+ if err := pool.Ping(ctx); err != nil {
+ fmt.Printf("Skipping integration tests: database not reachable: %v\n", err)
+ pool.Close()
+ os.Exit(0)
+ }
testPool = pool
testUserID, testWorkspaceID, err = setupIntegrationTestFixture(ctx, pool)
diff --git a/server/internal/handler/handler_test.go b/server/internal/handler/handler_test.go
index db65ea1927..3251482bcc 100644
--- a/server/internal/handler/handler_test.go
+++ b/server/internal/handler/handler_test.go
@@ -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()