mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-08 01:39:12 +00:00
fix(test): replace Unix-only assumptions with cross-platform alternatives (#14906)
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user