mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
perf(test): drop redundant memory reindex integration case
This commit is contained in:
@@ -5,7 +5,6 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi }
|
||||
import { getMemorySearchManager, type MemoryIndexManager } from "./index.js";
|
||||
|
||||
let embedBatchCalls = 0;
|
||||
let failEmbeddings = false;
|
||||
|
||||
vi.mock("./embeddings.js", () => {
|
||||
const embedText = (text: string) => {
|
||||
@@ -23,9 +22,6 @@ vi.mock("./embeddings.js", () => {
|
||||
embedQuery: async (text: string) => embedText(text),
|
||||
embedBatch: async (texts: string[]) => {
|
||||
embedBatchCalls += 1;
|
||||
if (failEmbeddings) {
|
||||
throw new Error("mock embeddings failed");
|
||||
}
|
||||
return texts.map(embedText);
|
||||
},
|
||||
},
|
||||
@@ -50,7 +46,6 @@ describe("memory index", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
embedBatchCalls = 0;
|
||||
failEmbeddings = false;
|
||||
workspaceDir = path.join(fixtureRoot, `case-${fixtureCount++}`);
|
||||
await fs.mkdir(workspaceDir, { recursive: true });
|
||||
indexPath = path.join(workspaceDir, "index.sqlite");
|
||||
@@ -204,45 +199,6 @@ describe("memory index", () => {
|
||||
expect(embedBatchCalls).toBe(afterFirst);
|
||||
});
|
||||
|
||||
it("preserves existing index when forced reindex fails", async () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
workspace: workspaceDir,
|
||||
memorySearch: {
|
||||
provider: "openai",
|
||||
model: "mock-embed",
|
||||
store: { path: indexPath, vector: { enabled: false } },
|
||||
sync: { watch: false, onSessionStart: false, onSearch: false },
|
||||
query: { minScore: 0 },
|
||||
cache: { enabled: false },
|
||||
},
|
||||
},
|
||||
list: [{ id: "main", default: true }],
|
||||
},
|
||||
};
|
||||
const result = await getMemorySearchManager({ cfg, agentId: "main" });
|
||||
expect(result.manager).not.toBeNull();
|
||||
if (!result.manager) {
|
||||
throw new Error("manager missing");
|
||||
}
|
||||
manager = result.manager;
|
||||
|
||||
await manager.sync({ force: true });
|
||||
const before = manager.status();
|
||||
expect(before.files).toBeGreaterThan(0);
|
||||
|
||||
failEmbeddings = true;
|
||||
await expect(manager.sync({ force: true })).rejects.toThrow(/mock embeddings failed/i);
|
||||
|
||||
const after = manager.status();
|
||||
expect(after.files).toBe(before.files);
|
||||
expect(after.chunks).toBe(before.chunks);
|
||||
|
||||
const files = await fs.readdir(workspaceDir);
|
||||
expect(files.some((name) => name.includes(".tmp-"))).toBe(false);
|
||||
});
|
||||
|
||||
it("finds keyword matches via hybrid search when query embedding is zero", async () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
|
||||
Reference in New Issue
Block a user