mirror of https://github.com/openclaw/openclaw.git
test: route openclaw root through boundary config
This commit is contained in:
parent
cc62fd38f6
commit
0ad2da060e
|
|
@ -39,8 +39,8 @@ function expectResolvedPackageRoot(
|
|||
return expect(asyncResolver(opts)).resolves.toBe(expected);
|
||||
}
|
||||
|
||||
vi.mock("node:fs", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:fs")>();
|
||||
const mockFsModule = async (importOriginal: () => Promise<typeof import("node:fs")>) => {
|
||||
const actual = await importOriginal();
|
||||
const wrapped = {
|
||||
...actual,
|
||||
existsSync: (p: string) =>
|
||||
|
|
@ -80,10 +80,12 @@ vi.mock("node:fs", async (importOriginal) => {
|
|||
: actual.realpathSync(p),
|
||||
};
|
||||
return { ...wrapped, default: wrapped };
|
||||
});
|
||||
};
|
||||
|
||||
vi.mock("node:fs/promises", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:fs/promises")>();
|
||||
const mockFsPromisesModule = async (
|
||||
importOriginal: () => Promise<typeof import("node:fs/promises")>,
|
||||
) => {
|
||||
const actual = await importOriginal();
|
||||
const wrapped = {
|
||||
...actual,
|
||||
readFile: async (p: string, encoding?: BufferEncoding) => {
|
||||
|
|
@ -98,21 +100,28 @@ vi.mock("node:fs/promises", async (importOriginal) => {
|
|||
},
|
||||
};
|
||||
return { ...wrapped, default: wrapped };
|
||||
});
|
||||
};
|
||||
|
||||
describe("resolveOpenClawPackageRoot", () => {
|
||||
let resolveOpenClawPackageRoot: typeof import("./openclaw-root.js").resolveOpenClawPackageRoot;
|
||||
let resolveOpenClawPackageRootSync: typeof import("./openclaw-root.js").resolveOpenClawPackageRootSync;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ resolveOpenClawPackageRoot, resolveOpenClawPackageRootSync } =
|
||||
await import("./openclaw-root.js"));
|
||||
beforeEach(() => {
|
||||
state.entries.clear();
|
||||
state.realpaths.clear();
|
||||
state.realpathErrors.clear();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
vi.doUnmock("node:fs");
|
||||
vi.doUnmock("node:fs/promises");
|
||||
vi.doMock("node:fs", mockFsModule);
|
||||
vi.doMock("node:fs/promises", mockFsPromisesModule);
|
||||
({ resolveOpenClawPackageRoot, resolveOpenClawPackageRootSync } =
|
||||
await import("./openclaw-root.js"));
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "resolves package root from .bin argv1",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ describe("isUnitConfigTestFile", () => {
|
|||
),
|
||||
).toBe(false);
|
||||
expect(isUnitConfigTestFile("src/infra/matrix-plugin-helper.test.ts")).toBe(false);
|
||||
expect(isUnitConfigTestFile("src/infra/openclaw-root.test.ts")).toBe(false);
|
||||
expect(isUnitConfigTestFile("src/plugin-sdk/facade-runtime.test.ts")).toBe(false);
|
||||
expect(isUnitConfigTestFile("src/plugins/loader.test.ts")).toBe(false);
|
||||
expect(isUnitConfigTestFile("test/extension-test-boundary.test.ts")).toBe(false);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export const unitTestIncludePatterns = [
|
|||
];
|
||||
|
||||
export const boundaryTestFiles = [
|
||||
"src/infra/openclaw-root.test.ts",
|
||||
"test/extension-plugin-sdk-boundary.test.ts",
|
||||
"test/extension-test-boundary.test.ts",
|
||||
"test/plugin-extension-import-boundary.test.ts",
|
||||
|
|
@ -39,6 +40,7 @@ export const unitTestAdditionalExcludePatterns = [
|
|||
"src/commands/**",
|
||||
"src/channels/plugins/contracts/**",
|
||||
"src/plugins/contracts/**",
|
||||
"src/infra/openclaw-root.test.ts",
|
||||
...bundledPluginDependentUnitTestFiles,
|
||||
"src/config/doc-baseline.integration.test.ts",
|
||||
"src/config/schema.base.generated.test.ts",
|
||||
|
|
|
|||
Loading…
Reference in New Issue