test: tighten sandbox assertions · openclaw/openclaw@ce09e59
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -169,13 +169,11 @@ describe("sandbox config merges", () => {
|
169 | 169 | strictHostKeyChecking: false, |
170 | 170 | }, |
171 | 171 | }); |
172 | | -expect(ssh).toMatchObject({ |
173 | | -target: "agent@example.com:2222", |
174 | | -command: "ssh", |
175 | | -identityFile: "~/.ssh/global", |
176 | | -certificateFile: "~/.ssh/agent-cert.pub", |
177 | | -strictHostKeyChecking: false, |
178 | | -}); |
| 172 | +expect(ssh.target).toBe("agent@example.com:2222"); |
| 173 | +expect(ssh.command).toBe("ssh"); |
| 174 | +expect(ssh.identityFile).toBe("~/.ssh/global"); |
| 175 | +expect(ssh.certificateFile).toBe("~/.ssh/agent-cert.pub"); |
| 176 | +expect(ssh.strictHostKeyChecking).toBe(false); |
179 | 177 | |
180 | 178 | const sshShared = resolveSandboxSshConfig({ |
181 | 179 | scope: "shared", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -241,12 +241,9 @@ describe("ensureSandboxContainer config-hash recreation", () => {
|
241 | 241 | throw new Error("expected recreated docker create call"); |
242 | 242 | } |
243 | 243 | expect(createCall.args).toContain(`openclaw.configHash=${newHash}`); |
244 | | -expect(registryMocks.updateRegistry).toHaveBeenCalledWith( |
245 | | -expect.objectContaining({ |
246 | | -containerName: "oc-test-shared", |
247 | | -configHash: newHash, |
248 | | -}), |
249 | | -); |
| 244 | +const registryUpdate = registryMocks.updateRegistry.mock.calls.at(-1)?.[0]; |
| 245 | +expect(registryUpdate?.containerName).toBe("oc-test-shared"); |
| 246 | +expect(registryUpdate?.configHash).toBe(newHash); |
250 | 247 | }); |
251 | 248 | |
252 | 249 | it("applies custom binds after workspace mounts so overlapping binds can override", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,9 +13,10 @@ describe("execDockerRaw", () => {
|
13 | 13 | } |
14 | 14 | |
15 | 15 | expect(err).toBeInstanceOf(Error); |
16 | | -expect(err).toMatchObject({ code: "INVALID_CONFIG" }); |
17 | | -expect((err as Error).message).toContain("Sandbox mode requires Docker"); |
18 | | -expect((err as Error).message).toContain("agents.defaults.sandbox.mode=off"); |
| 16 | +const error = err as Error & { code?: string }; |
| 17 | +expect(error.code).toBe("INVALID_CONFIG"); |
| 18 | +expect(error.message).toContain("Sandbox mode requires Docker"); |
| 19 | +expect(error.message).toContain("agents.defaults.sandbox.mode=off"); |
19 | 20 | }); |
20 | 21 | }); |
21 | 22 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,7 +57,14 @@ function runWritePlan(args: string[], input?: string, env?: NodeJS.ProcessEnv) {
|
57 | 57 | } |
58 | 58 | |
59 | 59 | async function expectPathMissing(targetPath: string): Promise<void> { |
60 | | -await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 60 | +let err: unknown; |
| 61 | +try { |
| 62 | +await fs.access(targetPath); |
| 63 | +} catch (caught) { |
| 64 | +err = caught; |
| 65 | +} |
| 66 | +expect(err).toBeInstanceOf(Error); |
| 67 | +expect((err as NodeJS.ErrnoException).code).toBe("ENOENT"); |
61 | 68 | } |
62 | 69 | |
63 | 70 | const hasAbsolutePythonCandidate = SANDBOX_PINNED_MUTATION_PYTHON_CANDIDATES.some((candidate) => |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -116,9 +116,7 @@ describe("sandbox fs bridge local backend e2e", () => {
|
116 | 116 | await expect( |
117 | 117 | fs.readFile(path.join(workspaceDir, "nested", "hello.txt"), "utf8"), |
118 | 118 | ).resolves.toBe("from-backend"); |
119 | | -expect(scripts).toEqual( |
120 | | -expect.arrayContaining([expect.stringContaining("operation = sys.argv[1]")]), |
121 | | -); |
| 119 | +expect(scripts.some((script) => script.includes("operation = sys.argv[1]"))).toBe(true); |
122 | 120 | } finally { |
123 | 121 | await fs.rm(stateDir, { recursive: true, force: true }); |
124 | 122 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。