From 493288bf2e2c73ca4cd064362f631b8031066108 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 12 Apr 2026 10:07:06 +0100 Subject: [PATCH] test(commands): share memory recall doctor mock setup --- src/commands/doctor-memory-search.test.ts | 119 ++++++++-------------- 1 file changed, 43 insertions(+), 76 deletions(-) diff --git a/src/commands/doctor-memory-search.test.ts b/src/commands/doctor-memory-search.test.ts index 90c921154d9..1e6a3f42dde 100644 --- a/src/commands/doctor-memory-search.test.ts +++ b/src/commands/doctor-memory-search.test.ts @@ -80,6 +80,47 @@ import { noteMemorySearchHealth } from "./doctor-memory-search.js"; import { maybeRepairMemoryRecallHealth, noteMemoryRecallHealth } from "./doctor-memory-search.js"; import { detectLegacyWorkspaceDirs } from "./doctor-workspace.js"; +function resetMemoryRecallMocks() { + auditShortTermPromotionArtifacts.mockReset(); + auditShortTermPromotionArtifacts.mockResolvedValue({ + storePath: "/tmp/agent-default/workspace/memory/.dreams/short-term-recall.json", + lockPath: "/tmp/agent-default/workspace/memory/.dreams/short-term-promotion.lock", + exists: true, + entryCount: 1, + promotedCount: 0, + spacedEntryCount: 0, + conceptTaggedEntryCount: 1, + invalidEntryCount: 0, + issues: [], + }); + auditDreamingArtifacts.mockReset(); + auditDreamingArtifacts.mockResolvedValue({ + sessionCorpusDir: "/tmp/agent-default/workspace/memory/.dreams/session-corpus", + sessionCorpusFileCount: 0, + suspiciousSessionCorpusFileCount: 0, + suspiciousSessionCorpusLineCount: 0, + sessionIngestionPath: "/tmp/agent-default/workspace/memory/.dreams/session-ingestion.json", + sessionIngestionExists: false, + issues: [], + }); + repairDreamingArtifacts.mockReset(); + repairDreamingArtifacts.mockResolvedValue({ + changed: false, + archivedDreamsDiary: false, + archivedSessionCorpus: false, + archivedSessionIngestion: false, + archivedPaths: [], + warnings: [], + }); + repairShortTermPromotionArtifacts.mockReset(); + repairShortTermPromotionArtifacts.mockResolvedValue({ + changed: false, + removedInvalidEntries: 0, + rewroteStore: false, + removedStaleLock: false, + }); +} + describe("noteMemorySearchHealth", () => { const cfg = {} as OpenClawConfig; @@ -115,44 +156,7 @@ describe("noteMemorySearchHealth", () => { }); checkQmdBinaryAvailability.mockReset(); checkQmdBinaryAvailability.mockResolvedValue({ available: true }); - auditShortTermPromotionArtifacts.mockReset(); - auditShortTermPromotionArtifacts.mockResolvedValue({ - storePath: "/tmp/agent-default/workspace/memory/.dreams/short-term-recall.json", - lockPath: "/tmp/agent-default/workspace/memory/.dreams/short-term-promotion.lock", - exists: true, - entryCount: 1, - promotedCount: 0, - spacedEntryCount: 0, - conceptTaggedEntryCount: 1, - invalidEntryCount: 0, - issues: [], - }); - auditDreamingArtifacts.mockReset(); - auditDreamingArtifacts.mockResolvedValue({ - sessionCorpusDir: "/tmp/agent-default/workspace/memory/.dreams/session-corpus", - sessionCorpusFileCount: 0, - suspiciousSessionCorpusFileCount: 0, - suspiciousSessionCorpusLineCount: 0, - sessionIngestionPath: "/tmp/agent-default/workspace/memory/.dreams/session-ingestion.json", - sessionIngestionExists: false, - issues: [], - }); - repairDreamingArtifacts.mockReset(); - repairDreamingArtifacts.mockResolvedValue({ - changed: false, - archivedDreamsDiary: false, - archivedSessionCorpus: false, - archivedSessionIngestion: false, - archivedPaths: [], - warnings: [], - }); - repairShortTermPromotionArtifacts.mockReset(); - repairShortTermPromotionArtifacts.mockResolvedValue({ - changed: false, - removedInvalidEntries: 0, - rewroteStore: false, - removedStaleLock: false, - }); + resetMemoryRecallMocks(); }); it("does not warn when local provider is set with no explicit modelPath (default model fallback)", async () => { @@ -452,44 +456,7 @@ describe("memory recall doctor integration", () => { beforeEach(() => { note.mockClear(); - auditShortTermPromotionArtifacts.mockReset(); - auditShortTermPromotionArtifacts.mockResolvedValue({ - storePath: "/tmp/agent-default/workspace/memory/.dreams/short-term-recall.json", - lockPath: "/tmp/agent-default/workspace/memory/.dreams/short-term-promotion.lock", - exists: true, - entryCount: 1, - promotedCount: 0, - spacedEntryCount: 0, - conceptTaggedEntryCount: 1, - invalidEntryCount: 0, - issues: [], - }); - auditDreamingArtifacts.mockReset(); - auditDreamingArtifacts.mockResolvedValue({ - sessionCorpusDir: "/tmp/agent-default/workspace/memory/.dreams/session-corpus", - sessionCorpusFileCount: 0, - suspiciousSessionCorpusFileCount: 0, - suspiciousSessionCorpusLineCount: 0, - sessionIngestionPath: "/tmp/agent-default/workspace/memory/.dreams/session-ingestion.json", - sessionIngestionExists: false, - issues: [], - }); - repairDreamingArtifacts.mockReset(); - repairDreamingArtifacts.mockResolvedValue({ - changed: false, - archivedDreamsDiary: false, - archivedSessionCorpus: false, - archivedSessionIngestion: false, - archivedPaths: [], - warnings: [], - }); - repairShortTermPromotionArtifacts.mockReset(); - repairShortTermPromotionArtifacts.mockResolvedValue({ - changed: false, - removedInvalidEntries: 0, - rewroteStore: false, - removedStaleLock: false, - }); + resetMemoryRecallMocks(); }); function createPrompter(overrides: Partial = {}): DoctorPrompter {