From c5a38d888443131b36039a86a7ea7b5afe14fa22 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Sun, 26 Jul 2026 12:58:48 -0700 Subject: [PATCH] test: cover orphan reconcile and database-health PG stubs Pin reconcileOrphanedTaskDirsImpl empty result and getDatabaseHealthImpl always-healthy sentinel under backendMode so inventory category (e) stays aligned with production self-healing and health call sites. --- ...sqlite-production-reader-inventory.test.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/core/src/__tests__/postgres/sqlite-production-reader-inventory.test.ts b/packages/core/src/__tests__/postgres/sqlite-production-reader-inventory.test.ts index 0c0e8221ef..38ce6d9522 100644 --- a/packages/core/src/__tests__/postgres/sqlite-production-reader-inventory.test.ts +++ b/packages/core/src/__tests__/postgres/sqlite-production-reader-inventory.test.ts @@ -16,8 +16,9 @@ import { isTaskArchivedImpl, isTaskIdPresentInArchivedTasksTableImpl, } from "../../task-store/task-id-integrity.js"; -import { getMergeRequestRecordImpl } from "../../task-store/task-store-helpers.js"; +import { getMergeRequestRecordImpl, refreshDatabaseHealthImpl } from "../../task-store/task-store-helpers.js"; import { + getDatabaseHealthImpl, getSettingsSyncImpl, getTaskWorkflowSelectionImpl, healthCheckImpl, @@ -25,6 +26,7 @@ import { import { getWorkflowPromptOverridesImpl } from "../../task-store/task-mutation-ops.js"; import { getWorkflowSettingValuesImpl } from "../../task-store/branch-and-pr-entities.js"; import { getRunAuditEventsImpl } from "../../task-store/project-store-ops.js"; +import { reconcileOrphanedTaskDirsImpl } from "../../task-store/lifecycle-ops.js"; import type { TaskStore } from "../../store.js"; const workspaceRoot = join(__dirname, "..", "..", "..", "..", ".."); @@ -218,4 +220,29 @@ describe("incomplete PG sync-reader stubs (shipped helpers)", () => { it("healthCheckImpl returns true under backend mode (real health is AsyncDataLayer.ping)", () => { expect(healthCheckImpl(backendModeStore())).toBe(true); }); + + it("getDatabaseHealthImpl returns always-healthy sentinel under backend mode without opening SQLite", () => { + const health = getDatabaseHealthImpl(backendModeStore()); + expect(health).toEqual({ + healthy: true, + corruptionDetected: false, + corruptionErrors: [], + lastCheckedAt: null, + isRunning: false, + }); + }); + + it("refreshDatabaseHealthImpl delegates to healthy sentinel under backend mode (no integrity_check)", () => { + const store = backendModeStore(); + // TaskStore.refreshDatabaseHealth / getDatabaseHealth are methods that call the impls. + store.getDatabaseHealth = () => getDatabaseHealthImpl(store); + const health = refreshDatabaseHealthImpl(store); + expect(health.healthy).toBe(true); + expect(health.corruptionDetected).toBe(false); + }); + + it("reconcileOrphanedTaskDirsImpl returns empty recovered/skipped under backend mode (PG self-healing no-op)", async () => { + const result = await reconcileOrphanedTaskDirsImpl(backendModeStore(), {}); + expect(result).toEqual({ recovered: [], skipped: [] }); + }); });