Files
windmill/cli/test/remote_key_within_folder_unit.test.ts
T
Ruben FiszelandClaude Opus 5.5 46a64b1b46 fix(cli): dev server and sync path handling improvements
Dev servers bind to localhost by default (new --host option) and sync keeps paths within the project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 18:53:29 +00:00

31 lines
836 B
TypeScript

import { expect, test } from "bun:test";
import { join } from "node:path";
import { remoteKeyWithinFolder } from "../src/commands/sync/sync.ts";
const FILESET = join("f", "res", "data.fileset");
test("fileset keys and module names land inside their folder", () => {
expect(remoteKeyWithinFolder(FILESET, "q.sql")).toBe(join(FILESET, "q.sql"));
expect(remoteKeyWithinFolder(FILESET, "models/staging/a.sql")).toBe(
join(FILESET, "models", "staging", "a.sql"),
);
});
test("fileset keys that are not plain relative paths are refused", () => {
for (const key of [
"../cleanup.sh",
"a/../../b.sh",
"/etc/cron.d/x",
"C:/x.ts",
"a\\..\\..\\b.ts",
"a\0b",
"a//b",
"./a",
"",
]) {
expect(() => remoteKeyWithinFolder(FILESET, key)).toThrow(
/must be a relative path/,
);
}
});