Skip to content

Commit 5cf0acb

Browse files
committed
update mock and tool unwrap for factory pattern and agentId migration
1 parent 2b81dad commit 5cf0acb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎extensions/memory-lancedb/index.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ describe("memory plugin e2e", () => {
140140
data: [{ embedding: [0.1, 0.2, 0.3] }],
141141
}));
142142
const toArray = vi.fn(async () => []);
143-
const limit = vi.fn(() => ({ toArray }));
143+
const where = vi.fn(() => ({ toArray }));
144+
const limit = vi.fn(() => ({ toArray, where }));
144145
const vectorSearch = vi.fn(() => ({ limit }));
145146

146147
vi.resetModules();
@@ -153,6 +154,7 @@ describe("memory plugin e2e", () => {
153154
connect: vi.fn(async () => ({
154155
tableNames: vi.fn(async () => ["memories"]),
155156
openTable: vi.fn(async () => ({
157+
schema: vi.fn(async () => ({ fields: [{ name: "agentId" }] })),
156158
vectorSearch,
157159
countRows: vi.fn(async () => 0),
158160
add: vi.fn(async () => undefined),
@@ -202,8 +204,12 @@ describe("memory plugin e2e", () => {
202204

203205
// oxlint-disable-next-line typescript/no-explicit-any
204206
memoryPlugin.register(mockApi as any);
205-
const recallTool = registeredTools.find((t) => t.opts?.name === "memory_recall")?.tool;
206-
expect(recallTool).toBeDefined();
207+
const recallToolEntry = registeredTools.find((t) => t.opts?.name === "memory_recall");
208+
expect(recallToolEntry).toBeDefined();
209+
const recallTool =
210+
typeof recallToolEntry.tool === "function"
211+
? recallToolEntry.tool({})
212+
: recallToolEntry.tool;
207213
await recallTool.execute("test-call-dims", { query: "hello dimensions" });
208214

209215
expect(embeddingsCreate).toHaveBeenCalledWith({

0 commit comments

Comments
 (0)