summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/handlers_test.go')
-rw-r--r--internal/handlers/handlers_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index bb383aa..9d92faa 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -2355,3 +2355,25 @@ func TestHandleTimeline_IncludesBudgetStatusWhenTrackedTaskExists(t *testing.T)
}
}
+func TestPingDB_HealthyStore_ReturnsNil(t *testing.T) {
+ h, cleanup := setupTestHandler(t)
+ defer cleanup()
+
+ if err := h.PingDB(context.Background()); err != nil {
+ t.Errorf("PingDB() = %v, want nil for a healthy store", err)
+ }
+}
+
+// This is the regression test for the actual incident: a health check that
+// can't observe a broken database isn't a health check. If PingDB stops
+// reflecting real DB reachability -- e.g. someone "simplifies" it back to
+// an unconditional nil -- this must fail.
+func TestPingDB_ClosedStore_ReturnsError(t *testing.T) {
+ h, cleanup := setupTestHandler(t)
+ cleanup() // close the underlying DB before pinging it
+
+ if err := h.PingDB(context.Background()); err == nil {
+ t.Error("PingDB() = nil, want an error for a closed/unreachable store")
+ }
+}
+