test: fail fast on overflow compaction calls · openclaw/openclaw@6bb5c9f
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
src/agents/pi-embedded-runner
| Original file line number | Diff line number | Diff line change |
|---|
@@ -150,16 +150,23 @@ type MockWithCalls = {
|
150 | 150 | }; |
151 | 151 | |
152 | 152 | function mockCallArg(mock: MockWithCalls, callIndex = 0, argIndex = 0): unknown { |
153 | | -const call = mock.mock.calls[callIndex]; |
154 | | -expect(call).toBeDefined(); |
155 | | -return call?.[argIndex]; |
| 153 | +const call = mock.mock.calls.at(callIndex); |
| 154 | +if (!call) { |
| 155 | +throw new Error(`Expected mock call ${callIndex}`); |
| 156 | +} |
| 157 | +if (argIndex >= call.length) { |
| 158 | +throw new Error(`Expected mock call ${callIndex} argument ${argIndex}`); |
| 159 | +} |
| 160 | +return call[argIndex]; |
156 | 161 | } |
157 | 162 | |
158 | 163 | function expectRecordFields( |
159 | 164 | record: unknown, |
160 | 165 | expected: Record<string, unknown>, |
161 | 166 | ): Record<string, unknown> { |
162 | | -expect(record).toBeDefined(); |
| 167 | +if (!record || typeof record !== "object") { |
| 168 | +throw new Error("Expected record"); |
| 169 | +} |
163 | 170 | const actual = record as Record<string, unknown>; |
164 | 171 | for (const [key, value] of Object.entries(expected)) { |
165 | 172 | expect(actual[key]).toEqual(value); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。