mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 18:30:42 +00:00
test: tighten memory cleanup assertions
This commit is contained in:
@@ -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[] }>;
|
||||
};
|
||||
|
||||
@@ -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"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user