Make English the repository working language (#5)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,18 +25,18 @@ describe("workspace-guard", () => {
|
||||
|
||||
const guard = (workspace: string) => assertWorkspaceAllowed({ workspace });
|
||||
|
||||
it("已存在的目录放行并返回 realpath", async () => {
|
||||
it("an existing directory is allowed and its realpath returned", async () => {
|
||||
const ws = await guard(path.join(projectA, "workdir"));
|
||||
expect(ws).toBe(await fs.realpath(path.join(projectA, "workdir")));
|
||||
});
|
||||
|
||||
it("Project 目录之外的任意目录同样放行", async () => {
|
||||
it("any directory outside the Project directory is likewise allowed", async () => {
|
||||
const outside = path.join(root, "elsewhere");
|
||||
await fs.mkdir(outside, { recursive: true });
|
||||
await expect(guard(outside)).resolves.toBe(await fs.realpath(outside));
|
||||
});
|
||||
|
||||
it("符号链接解析为 realpath 后返回", async () => {
|
||||
it("symlinks resolve to their realpath before returning", async () => {
|
||||
const outside = path.join(root, "linked");
|
||||
await fs.mkdir(outside, { recursive: true });
|
||||
const link = path.join(projectA, "escape");
|
||||
@@ -44,14 +44,14 @@ describe("workspace-guard", () => {
|
||||
await expect(guard(link)).resolves.toBe(await fs.realpath(outside));
|
||||
});
|
||||
|
||||
it("不存在的路径 → 400 workspace_not_found", async () => {
|
||||
it("a nonexistent path → 400 workspace_not_found", async () => {
|
||||
const err = await guard(path.join(projectA, "ghost")).catch((e: unknown) => e);
|
||||
expect(err).toBeInstanceOf(HttpError);
|
||||
expect((err as HttpError).status).toBe(400);
|
||||
expect((err as HttpError).code).toBe("workspace_not_found");
|
||||
});
|
||||
|
||||
it("文件(非目录)→ 400 workspace_not_found", async () => {
|
||||
it("a file (not a directory) → 400 workspace_not_found", async () => {
|
||||
const file = path.join(projectA, "a-file.txt");
|
||||
await fs.writeFile(file, "x", "utf8");
|
||||
const err = await guard(file).catch((e: unknown) => e);
|
||||
|
||||
Reference in New Issue
Block a user