mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
fix(test): make sandbox fs-path expectations cross-platform
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { SandboxContext } from "./types.js";
|
||||
import {
|
||||
@@ -41,12 +42,12 @@ function createSandbox(overrides?: Partial<SandboxContext>): SandboxContext {
|
||||
describe("parseSandboxBindMount", () => {
|
||||
it("parses bind mode and writeability", () => {
|
||||
expect(parseSandboxBindMount("/tmp/a:/workspace-a:ro")).toEqual({
|
||||
hostRoot: "/tmp/a",
|
||||
hostRoot: path.resolve("/tmp/a"),
|
||||
containerRoot: "/workspace-a",
|
||||
writable: false,
|
||||
});
|
||||
expect(parseSandboxBindMount("/tmp/b:/workspace-b:rw")).toEqual({
|
||||
hostRoot: "/tmp/b",
|
||||
hostRoot: path.resolve("/tmp/b"),
|
||||
containerRoot: "/workspace-b",
|
||||
writable: true,
|
||||
});
|
||||
@@ -70,7 +71,9 @@ describe("resolveSandboxFsPathWithMounts", () => {
|
||||
mounts,
|
||||
});
|
||||
|
||||
expect(resolved.hostPath).toBe("/tmp/workspace-two/docs/AGENTS.md");
|
||||
expect(resolved.hostPath).toBe(
|
||||
path.join(path.resolve("/tmp/workspace-two"), "docs", "AGENTS.md"),
|
||||
);
|
||||
expect(resolved.containerPath).toBe("/workspace-two/docs/AGENTS.md");
|
||||
expect(resolved.relativePath).toBe("/workspace-two/docs/AGENTS.md");
|
||||
expect(resolved.writable).toBe(false);
|
||||
@@ -86,7 +89,7 @@ describe("resolveSandboxFsPathWithMounts", () => {
|
||||
defaultContainerRoot: sandbox.containerWorkdir,
|
||||
mounts,
|
||||
});
|
||||
expect(resolved.hostPath).toBe("/tmp/workspace/src/index.ts");
|
||||
expect(resolved.hostPath).toBe(path.join(path.resolve("/tmp/workspace"), "src", "index.ts"));
|
||||
expect(resolved.containerPath).toBe("/workspace/src/index.ts");
|
||||
expect(resolved.relativePath).toBe("src/index.ts");
|
||||
expect(resolved.writable).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user