test: tighten memory cleanup assertions

This commit is contained in:
Shakker
2026-05-09 02:58:03 +01:00
parent 4fe43b9eaf
commit 02e60e293f
3 changed files with 15 additions and 3 deletions

View File

@@ -21,6 +21,10 @@ const resolveCommandSecretRefsViaGateway = vi.hoisted(() =>
})),
);
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
}
vi.mock("./cli.host.runtime.js", async () => {
const [runtimeCli, runtimeCore, runtimeFiles] = await Promise.all([
import("openclaw/plugin-sdk/memory-core-host-runtime-cli"),
@@ -589,7 +593,7 @@ describe("memory cli", () => {
await runMemoryCli(["status", "--fix"]);
expectLogged(log, "Repair: rewrote store");
await expect(fs.stat(lockPath)).rejects.toThrow();
await expectPathMissing(lockPath);
const repaired = JSON.parse(await fs.readFile(storePath, "utf-8")) as {
entries: Record<string, { conceptTags?: string[] }>;
};

View File

@@ -6,6 +6,10 @@ import { createMemoryCoreTestHarness } from "./test-helpers.js";
const { createTempWorkspace } = createMemoryCoreTestHarness();
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
}
function requireInlinePath(result: { inlinePath?: string }): string {
if (!result.inlinePath) {
throw new Error("Expected inline dreaming markdown path");
@@ -127,6 +131,6 @@ describe("dreaming markdown storage", () => {
expect(content).toContain("# Deep Sleep");
expect(content).toContain("- Promoted: durable preference");
await expect(fs.access(path.join(workspaceDir, "DREAMS.md"))).rejects.toThrow();
await expectPathMissing(path.join(workspaceDir, "DREAMS.md"));
});
});

View File

@@ -29,6 +29,10 @@ const MEMORY_EMBEDDING_PROVIDERS_KEY = Symbol.for("openclaw.memoryEmbeddingProvi
const MCPORTER_STATE_KEY = Symbol.for("openclaw.mcporterState");
const QMD_EMBED_QUEUE_KEY = Symbol.for("openclaw.qmdEmbedQueueTail");
async function expectPathMissing(targetPath: string): Promise<void> {
await expect(fs.lstat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
}
interface MockChild extends EventEmitter {
stdout: EventEmitter;
stderr: EventEmitter;
@@ -4969,7 +4973,7 @@ describe("QmdMemoryManager", () => {
await fs.rm(defaultModelsDir, { recursive: true, force: true });
},
assert: async () => {
await expect(fs.lstat(customModelsDir)).rejects.toThrow();
await expectPathMissing(customModelsDir);
expect(logWarnMock).not.toHaveBeenCalledWith(
expect.stringContaining("failed to symlink qmd models directory"),
);