Skip to content

Commit fb0de09

Browse files
test: make zalo token resolver symlink test compatible with Windows
1 parent d17b970 commit fb0de09

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

extensions/zalo/src/token.test.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ import { describe, expect, it } from "vitest";
66
import { resolveZaloToken } from "./token.js";
77
import type { ZaloConfig } from "./types.js";
88

9+
const canCreateFileSymlinks = (() => {
10+
const probeDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-zalo-token-probe-"));
11+
const targetFile = path.join(probeDir, "target.txt");
12+
const linkFile = path.join(probeDir, "link.txt");
13+
try {
14+
fs.writeFileSync(targetFile, "target", "utf8");
15+
fs.symlinkSync(targetFile, linkFile, "file");
16+
return true;
17+
} catch {
18+
return false;
19+
} finally {
20+
fs.rmSync(probeDir, { recursive: true, force: true });
21+
}
22+
})();
23+
924
describe("resolveZaloToken", () => {
1025
it("falls back to top-level token for non-default accounts without overrides", () => {
1126
const cfg = {
@@ -75,7 +90,7 @@ describe("resolveZaloToken", () => {
7590
expect(res.source).toBe("config");
7691
});
7792

78-
it.runIf(process.platform !== "win32")("rejects symlinked token files", () => {
93+
it.skipIf(!canCreateFileSymlinks)("rejects symlinked token files", () => {
7994
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-zalo-token-"));
8095
const tokenFile = path.join(dir, "token.txt");
8196
const tokenLink = path.join(dir, "token-link.txt");

0 commit comments

Comments
 (0)