test: fix daemon program args fs mocks
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
const access = vi.fn();
|
const fsMocks = vi.hoisted(() => ({
|
||||||
const realpath = vi.fn();
|
access: vi.fn(),
|
||||||
|
realpath: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
vi.mock("node:fs/promises", () => ({
|
vi.mock("node:fs/promises", () => ({
|
||||||
default: { access, realpath },
|
default: { access: fsMocks.access, realpath: fsMocks.realpath },
|
||||||
access,
|
access: fsMocks.access,
|
||||||
realpath,
|
realpath: fsMocks.realpath,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import { resolveGatewayProgramArguments } from "./program-args.js";
|
import { resolveGatewayProgramArguments } from "./program-args.js";
|
||||||
@@ -24,10 +26,10 @@ describe("resolveGatewayProgramArguments", () => {
|
|||||||
"node",
|
"node",
|
||||||
"/tmp/.npm/_npx/63c3/node_modules/.bin/clawdbot",
|
"/tmp/.npm/_npx/63c3/node_modules/.bin/clawdbot",
|
||||||
];
|
];
|
||||||
realpath.mockResolvedValue(
|
fsMocks.realpath.mockResolvedValue(
|
||||||
"/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/entry.js",
|
"/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/entry.js",
|
||||||
);
|
);
|
||||||
access.mockImplementation(async (target: string) => {
|
fsMocks.access.mockImplementation(async (target: string) => {
|
||||||
if (target === "/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/entry.js") {
|
if (target === "/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/entry.js") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,8 +52,8 @@ describe("resolveGatewayProgramArguments", () => {
|
|||||||
"node",
|
"node",
|
||||||
"/tmp/.npm/_npx/63c3/node_modules/.bin/clawdbot",
|
"/tmp/.npm/_npx/63c3/node_modules/.bin/clawdbot",
|
||||||
];
|
];
|
||||||
realpath.mockRejectedValue(new Error("no realpath"));
|
fsMocks.realpath.mockRejectedValue(new Error("no realpath"));
|
||||||
access.mockImplementation(async (target: string) => {
|
fsMocks.access.mockImplementation(async (target: string) => {
|
||||||
if (target === "/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/index.js") {
|
if (target === "/tmp/.npm/_npx/63c3/node_modules/clawdbot/dist/index.js") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user