mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:14:32 +00: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 { describe, expect, it } from "vitest";
|
||||||
import type { SandboxContext } from "./types.js";
|
import type { SandboxContext } from "./types.js";
|
||||||
import {
|
import {
|
||||||
@@ -41,12 +42,12 @@ function createSandbox(overrides?: Partial<SandboxContext>): SandboxContext {
|
|||||||
describe("parseSandboxBindMount", () => {
|
describe("parseSandboxBindMount", () => {
|
||||||
it("parses bind mode and writeability", () => {
|
it("parses bind mode and writeability", () => {
|
||||||
expect(parseSandboxBindMount("/tmp/a:/workspace-a:ro")).toEqual({
|
expect(parseSandboxBindMount("/tmp/a:/workspace-a:ro")).toEqual({
|
||||||
hostRoot: "/tmp/a",
|
hostRoot: path.resolve("/tmp/a"),
|
||||||
containerRoot: "/workspace-a",
|
containerRoot: "/workspace-a",
|
||||||
writable: false,
|
writable: false,
|
||||||
});
|
});
|
||||||
expect(parseSandboxBindMount("/tmp/b:/workspace-b:rw")).toEqual({
|
expect(parseSandboxBindMount("/tmp/b:/workspace-b:rw")).toEqual({
|
||||||
hostRoot: "/tmp/b",
|
hostRoot: path.resolve("/tmp/b"),
|
||||||
containerRoot: "/workspace-b",
|
containerRoot: "/workspace-b",
|
||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
@@ -70,7 +71,9 @@ describe("resolveSandboxFsPathWithMounts", () => {
|
|||||||
mounts,
|
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.containerPath).toBe("/workspace-two/docs/AGENTS.md");
|
||||||
expect(resolved.relativePath).toBe("/workspace-two/docs/AGENTS.md");
|
expect(resolved.relativePath).toBe("/workspace-two/docs/AGENTS.md");
|
||||||
expect(resolved.writable).toBe(false);
|
expect(resolved.writable).toBe(false);
|
||||||
@@ -86,7 +89,7 @@ describe("resolveSandboxFsPathWithMounts", () => {
|
|||||||
defaultContainerRoot: sandbox.containerWorkdir,
|
defaultContainerRoot: sandbox.containerWorkdir,
|
||||||
mounts,
|
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.containerPath).toBe("/workspace/src/index.ts");
|
||||||
expect(resolved.relativePath).toBe("src/index.ts");
|
expect(resolved.relativePath).toBe("src/index.ts");
|
||||||
expect(resolved.writable).toBe(true);
|
expect(resolved.writable).toBe(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user