test: guard memory lancedb mock calls · openclaw/openclaw@dbf0458
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
extensions/memory-lancedb
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,7 +71,11 @@ function createRuntimeLoader(
|
71 | 71 | type MockCallSource = { mock: { calls: Array<Array<unknown>> } }; |
72 | 72 | |
73 | 73 | function firstMockArg(source: MockCallSource, label: string, argIndex = 0) { |
74 | | -const arg = source.mock.calls[0]?.[argIndex]; |
| 74 | +const [call] = source.mock.calls; |
| 75 | +if (!call) { |
| 76 | +throw new Error(`expected ${label} call`); |
| 77 | +} |
| 78 | +const arg = call[argIndex]; |
75 | 79 | if (arg === undefined) { |
76 | 80 | throw new Error(`expected ${label} arg`); |
77 | 81 | } |
@@ -109,7 +113,9 @@ function expectToolExecute(tool: unknown, name?: string) {
|
109 | 113 | } |
110 | 114 | |
111 | 115 | function firstAddedMemory(add: ReturnType<typeof vi.fn>) { |
112 | | -const batch = add.mock.calls[0]?.[0] as Array<Record<string, unknown>> | undefined; |
| 116 | +const batch = firstMockArg(add as MockCallSource, "memory add") as |
| 117 | +| Array<Record<string, unknown>> |
| 118 | +| undefined; |
113 | 119 | const memory = batch?.[0]; |
114 | 120 | if (!memory) { |
115 | 121 | throw new Error("expected first added memory"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。