fix(test): replace Unix-only assumptions with cross-platform alternatives (#14906)

This commit is contained in:
Luke Parker
2026-02-24 23:03:18 +10:00
committed by GitHub
parent 06f25c78f6
commit 3d379c20c4
3 changed files with 19 additions and 10 deletions

View File

@@ -293,19 +293,26 @@ describe("tool.write", () => {
})
describe("error handling", () => {
test("throws error for paths outside project", async () => {
test("throws error when OS denies write access", async () => {
await using tmp = await tmpdir()
const outsidePath = "/etc/passwd"
const readonlyPath = path.join(tmp.path, "readonly.txt")
// Create a read-only file
await fs.writeFile(readonlyPath, "test", "utf-8")
await fs.chmod(readonlyPath, 0o444)
await Instance.provide({
directory: tmp.path,
fn: async () => {
const { FileTime } = await import("../../src/file/time")
FileTime.read(ctx.sessionID, readonlyPath)
const write = await WriteTool.init()
await expect(
write.execute(
{
filePath: outsidePath,
content: "test",
filePath: readonlyPath,
content: "new content",
},
ctx,
),