test: tighten memory cleanup assertions · openclaw/openclaw@02e60e2
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
File tree
extensions/memory-core/src
| Original file line number | Diff line number | Diff line change |
|---|
@@ -21,6 +21,10 @@ const resolveCommandSecretRefsViaGateway = vi.hoisted(() =>
|
21 | 21 | })), |
22 | 22 | ); |
23 | 23 | |
| 24 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 25 | +await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 26 | +} |
| 27 | + |
24 | 28 | vi.mock("./cli.host.runtime.js", async () => { |
25 | 29 | const [runtimeCli, runtimeCore, runtimeFiles] = await Promise.all([ |
26 | 30 | import("openclaw/plugin-sdk/memory-core-host-runtime-cli"), |
@@ -589,7 +593,7 @@ describe("memory cli", () => {
|
589 | 593 | await runMemoryCli(["status", "--fix"]); |
590 | 594 | |
591 | 595 | expectLogged(log, "Repair: rewrote store"); |
592 | | -await expect(fs.stat(lockPath)).rejects.toThrow(); |
| 596 | +await expectPathMissing(lockPath); |
593 | 597 | const repaired = JSON.parse(await fs.readFile(storePath, "utf-8")) as { |
594 | 598 | entries: Record<string, { conceptTags?: string[] }>; |
595 | 599 | }; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,6 +6,10 @@ import { createMemoryCoreTestHarness } from "./test-helpers.js";
|
6 | 6 | |
7 | 7 | const { createTempWorkspace } = createMemoryCoreTestHarness(); |
8 | 8 | |
| 9 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 10 | +await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 11 | +} |
| 12 | + |
9 | 13 | function requireInlinePath(result: { inlinePath?: string }): string { |
10 | 14 | if (!result.inlinePath) { |
11 | 15 | throw new Error("Expected inline dreaming markdown path"); |
@@ -127,6 +131,6 @@ describe("dreaming markdown storage", () => {
|
127 | 131 | expect(content).toContain("# Deep Sleep"); |
128 | 132 | expect(content).toContain("- Promoted: durable preference"); |
129 | 133 | |
130 | | -await expect(fs.access(path.join(workspaceDir, "DREAMS.md"))).rejects.toThrow(); |
| 134 | +await expectPathMissing(path.join(workspaceDir, "DREAMS.md")); |
131 | 135 | }); |
132 | 136 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,10 @@ const MEMORY_EMBEDDING_PROVIDERS_KEY = Symbol.for("openclaw.memoryEmbeddingProvi
|
29 | 29 | const MCPORTER_STATE_KEY = Symbol.for("openclaw.mcporterState"); |
30 | 30 | const QMD_EMBED_QUEUE_KEY = Symbol.for("openclaw.qmdEmbedQueueTail"); |
31 | 31 | |
| 32 | +async function expectPathMissing(targetPath: string): Promise<void> { |
| 33 | +await expect(fs.lstat(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 34 | +} |
| 35 | + |
32 | 36 | interface MockChild extends EventEmitter { |
33 | 37 | stdout: EventEmitter; |
34 | 38 | stderr: EventEmitter; |
@@ -4969,7 +4973,7 @@ describe("QmdMemoryManager", () => {
|
4969 | 4973 | await fs.rm(defaultModelsDir, { recursive: true, force: true }); |
4970 | 4974 | }, |
4971 | 4975 | assert: async () => { |
4972 | | -await expect(fs.lstat(customModelsDir)).rejects.toThrow(); |
| 4976 | +await expectPathMissing(customModelsDir); |
4973 | 4977 | expect(logWarnMock).not.toHaveBeenCalledWith( |
4974 | 4978 | expect.stringContaining("failed to symlink qmd models directory"), |
4975 | 4979 | ); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。