test(agents): cover bundled skills env override and dedupe setup
This commit is contained in:
@@ -2,7 +2,8 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { captureEnv } from "../../test-utils/env.js";
|
||||
import { resolveBundledSkillsDir } from "./bundled-dir.js";
|
||||
|
||||
async function writeSkill(dir: string, name: string) {
|
||||
@@ -15,14 +16,20 @@ async function writeSkill(dir: string, name: string) {
|
||||
}
|
||||
|
||||
describe("resolveBundledSkillsDir", () => {
|
||||
const originalOverride = process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
|
||||
beforeEach(() => {
|
||||
envSnapshot = captureEnv(["OPENCLAW_BUNDLED_SKILLS_DIR"]);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (originalOverride === undefined) {
|
||||
delete process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
|
||||
} else {
|
||||
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = originalOverride;
|
||||
}
|
||||
envSnapshot.restore();
|
||||
});
|
||||
|
||||
it("returns OPENCLAW_BUNDLED_SKILLS_DIR override when set", async () => {
|
||||
const overrideDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-bundled-override-"));
|
||||
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = ` ${overrideDir} `;
|
||||
expect(resolveBundledSkillsDir()).toBe(overrideDir);
|
||||
});
|
||||
|
||||
it("resolves bundled skills under a flattened dist layout", async () => {
|
||||
|
||||
Reference in New Issue
Block a user