test: guard container spawn mock call · openclaw/openclaw@ff7e6c7
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,17 @@ import {
|
5 | 5 | resolveCliContainerTarget, |
6 | 6 | } from "./container-target.js"; |
7 | 7 | |
| 8 | +function requireSpawnCall( |
| 9 | +spawnSync: ReturnType<typeof vi.fn>, |
| 10 | +index: number, |
| 11 | +): [string, string[], unknown?] { |
| 12 | +const call = spawnSync.mock.calls.at(index); |
| 13 | +if (!call) { |
| 14 | +throw new Error(`Expected spawnSync call ${index}`); |
| 15 | +} |
| 16 | +return call as [string, string[], unknown?]; |
| 17 | +} |
| 18 | + |
8 | 19 | describe("parseCliContainerArgs", () => { |
9 | 20 | it("extracts a root --container flag before the command", () => { |
10 | 21 | expect( |
@@ -356,10 +367,10 @@ describe("maybeRunCliInContainer", () => {
|
356 | 367 | spawnSync, |
357 | 368 | }); |
358 | 369 | |
359 | | -const podmanCall = spawnSync.mock.calls[2]; |
360 | | -expect(podmanCall?.[0]).toBe("podman"); |
361 | | -expect(podmanCall?.[1]).toContain("OPENCLAW_PROXY_URL=http://127.0.0.1:3128"); |
362 | | -if (podmanCall?.[2] === undefined) { |
| 370 | +const podmanCall = requireSpawnCall(spawnSync, 2); |
| 371 | +expect(podmanCall[0]).toBe("podman"); |
| 372 | +expect(podmanCall[1]).toContain("OPENCLAW_PROXY_URL=http://127.0.0.1:3128"); |
| 373 | +if (podmanCall[2] === undefined) { |
363 | 374 | throw new Error("Expected podman spawn options"); |
364 | 375 | } |
365 | 376 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。