mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:30:42 +00:00
test(memory): cover native Windows paths and locks
This commit is contained in:
@@ -29,6 +29,7 @@ import { createMemoryCoreTestHarness } from "./test-helpers.js";
|
||||
|
||||
const { createTempWorkspace } = createMemoryCoreTestHarness();
|
||||
const DREAMS_FILE_LOCKS_KEY = Symbol.for("openclaw.memoryCore.dreamingNarrative.fileLocks");
|
||||
const EXPECTS_POSIX_PRIVATE_FILE_MODE = process.platform !== "win32";
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
@@ -394,7 +395,9 @@ describe("appendNarrativeEntry", () => {
|
||||
});
|
||||
|
||||
const stat = await fs.stat(dreamsPath);
|
||||
expect(stat.mode & 0o777).toBe(0o600);
|
||||
if (EXPECTS_POSIX_PRIVATE_FILE_MODE) {
|
||||
expect(stat.mode & 0o777).toBe(0o600);
|
||||
}
|
||||
});
|
||||
|
||||
it("dedupes only exact diary duplicates while keeping distinct timestamps", async () => {
|
||||
|
||||
@@ -172,6 +172,7 @@ describe("memory index", () => {
|
||||
|
||||
afterEach(async () => {
|
||||
vi.useRealTimers();
|
||||
await Promise.all(Array.from(managersForCleanup).map((manager) => manager.close()));
|
||||
await closeAllMemorySearchManagers();
|
||||
clearRegistry();
|
||||
managersForCleanup.clear();
|
||||
|
||||
@@ -35,6 +35,10 @@ function createManagerStatus(params: {
|
||||
};
|
||||
}
|
||||
|
||||
function nativePath(candidate: string): string {
|
||||
return path.resolve(candidate);
|
||||
}
|
||||
|
||||
function createManagerMock(params: {
|
||||
backend: "qmd" | "builtin";
|
||||
provider: string;
|
||||
@@ -339,7 +343,7 @@ describe("getMemorySearchManager caching", () => {
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenCalledWith({
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace",
|
||||
cwd: nativePath("/tmp/workspace"),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -430,12 +434,12 @@ describe("getMemorySearchManager caching", () => {
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(1, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-a",
|
||||
cwd: nativePath("/tmp/workspace-a"),
|
||||
});
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(2, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-b",
|
||||
cwd: nativePath("/tmp/workspace-b"),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -582,12 +586,12 @@ describe("getMemorySearchManager caching", () => {
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(1, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-a",
|
||||
cwd: nativePath("/tmp/workspace-a"),
|
||||
});
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(2, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-b",
|
||||
cwd: nativePath("/tmp/workspace-b"),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -637,12 +641,12 @@ describe("getMemorySearchManager caching", () => {
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(1, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace",
|
||||
cwd: nativePath("/tmp/workspace"),
|
||||
});
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(2, {
|
||||
command: "qmd-alt",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace",
|
||||
cwd: nativePath("/tmp/workspace"),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -850,12 +854,12 @@ describe("getMemorySearchManager caching", () => {
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(1, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-a",
|
||||
cwd: nativePath("/tmp/workspace-a"),
|
||||
});
|
||||
expect(checkQmdBinaryAvailability).toHaveBeenNthCalledWith(2, {
|
||||
command: "qmd",
|
||||
env: process.env,
|
||||
cwd: "/tmp/workspace-b",
|
||||
cwd: nativePath("/tmp/workspace-b"),
|
||||
});
|
||||
|
||||
const fullAgain = await getMemorySearchManager({ cfg: firstCfg, agentId });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import AjvPkg from "ajv";
|
||||
import type { JsonSchemaObject } from "openclaw/plugin-sdk/config-schema";
|
||||
import { describe, expect, it } from "vitest";
|
||||
@@ -45,7 +46,7 @@ describe("resolveMemoryWikiConfig", () => {
|
||||
);
|
||||
|
||||
expect(config.vaultMode).toBe("bridge");
|
||||
expect(config.vault.path).toBe("/Users/tester/vaults/wiki");
|
||||
expect(config.vault.path).toBe(path.join("/Users/tester", "vaults", "wiki"));
|
||||
expect(config.vault.renderMode).toBe("obsidian");
|
||||
});
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ describe("searchMemoryWiki", () => {
|
||||
config,
|
||||
query: "maintainer-whois",
|
||||
mode: "source-evidence",
|
||||
maxResults: 2,
|
||||
maxResults: 5,
|
||||
});
|
||||
expect(evidenceResults.map((result) => result.path)).toContain("sources/maintainers.md");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user