Skip to content

Commit 64055fb

Browse files
committed
test: stabilize release verification fixtures
1 parent 6fedc30 commit 64055fb

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

test/codex-multi-auth-wrapper.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ describe("codex-multi-auth wrapper", () => {
3535
path.join(process.cwd(), "scripts", "codex-multi-auth.js"),
3636
path.join(scriptsDir, "codex-multi-auth.js"),
3737
);
38+
copyFileSync(
39+
path.join(process.cwd(), "scripts", "codex-routing.js"),
40+
path.join(scriptsDir, "codex-routing.js"),
41+
);
3842
writeFileSync(
3943
path.join(root, "package.json"),
40-
JSON.stringify({ version: "9.9.9-test" }, null, 2),
44+
JSON.stringify({ type: "module", version: "9.9.9-test" }, null, 2),
4145
"utf8",
4246
);
4347
writeFileSync(

test/oc-chatgpt-target-detection.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ async function loadTargetDetectionWithWin32PathMocks(): Promise<{
1515
detectOcChatgptMultiAuthTarget: typeof import("../lib/oc-chatgpt-target-detection.js").detectOcChatgptMultiAuthTarget;
1616
}> {
1717
vi.resetModules();
18+
vi.doMock("node:fs", async () => {
19+
const actual = await vi.importActual<typeof import("node:fs")>("node:fs");
20+
const isUncPath = (targetPath: unknown): targetPath is string =>
21+
typeof targetPath === "string" &&
22+
/^\\\\[^\\]+\\[^\\]+(?:\\|$)/.test(targetPath);
23+
return {
24+
...actual,
25+
existsSync: (targetPath: Parameters<typeof actual.existsSync>[0]) =>
26+
isUncPath(targetPath) ? false : actual.existsSync(targetPath),
27+
readdirSync: (
28+
targetPath: Parameters<typeof actual.readdirSync>[0],
29+
options?: Parameters<typeof actual.readdirSync>[1],
30+
) => {
31+
if (isUncPath(targetPath)) {
32+
const error = new Error("ENOENT: no such file or directory") as NodeJS.ErrnoException;
33+
error.code = "ENOENT";
34+
throw error;
35+
}
36+
return actual.readdirSync(targetPath, options as never);
37+
},
38+
};
39+
});
1840
vi.doMock("node:path", async () => {
1941
const actual =
2042
await vi.importActual<typeof import("node:path")>("node:path");
@@ -76,6 +98,7 @@ describe("oc-chatgpt target detection", () => {
7698
});
7799

78100
afterEach(async () => {
101+
vi.doUnmock("node:fs");
79102
vi.doUnmock("node:path");
80103
vi.resetModules();
81104
if (originalHome === undefined) delete process.env.HOME;

0 commit comments

Comments
 (0)