mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:24:33 +00:00
refactor(test): reuse env helper in workspace skill status tests
This commit is contained in:
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { withEnv } from "../test-utils/env.js";
|
||||||
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
import { buildWorkspaceSkillStatus } from "./skills-status.js";
|
||||||
import { writeSkill } from "./skills.e2e-test-helpers.js";
|
import { writeSkill } from "./skills.e2e-test-helpers.js";
|
||||||
|
|
||||||
@@ -60,7 +61,6 @@ describe("buildWorkspaceSkillStatus", () => {
|
|||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
||||||
const bundledDir = path.join(workspaceDir, ".bundled");
|
const bundledDir = path.join(workspaceDir, ".bundled");
|
||||||
const bundledSkillDir = path.join(bundledDir, "peekaboo");
|
const bundledSkillDir = path.join(bundledDir, "peekaboo");
|
||||||
const originalBundled = process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
|
|
||||||
|
|
||||||
await writeSkill({
|
await writeSkill({
|
||||||
dir: bundledSkillDir,
|
dir: bundledSkillDir,
|
||||||
@@ -69,8 +69,7 @@ describe("buildWorkspaceSkillStatus", () => {
|
|||||||
body: "# Peekaboo\n",
|
body: "# Peekaboo\n",
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
withEnv({ OPENCLAW_BUNDLED_SKILLS_DIR: bundledDir }, () => {
|
||||||
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = bundledDir;
|
|
||||||
const report = buildWorkspaceSkillStatus(workspaceDir, {
|
const report = buildWorkspaceSkillStatus(workspaceDir, {
|
||||||
managedSkillsDir: path.join(workspaceDir, ".managed"),
|
managedSkillsDir: path.join(workspaceDir, ".managed"),
|
||||||
config: { skills: { allowBundled: ["other-skill"] } },
|
config: { skills: { allowBundled: ["other-skill"] } },
|
||||||
@@ -80,13 +79,7 @@ describe("buildWorkspaceSkillStatus", () => {
|
|||||||
expect(skill).toBeDefined();
|
expect(skill).toBeDefined();
|
||||||
expect(skill?.blockedByAllowlist).toBe(true);
|
expect(skill?.blockedByAllowlist).toBe(true);
|
||||||
expect(skill?.eligible).toBe(false);
|
expect(skill?.eligible).toBe(false);
|
||||||
} finally {
|
});
|
||||||
if (originalBundled === undefined) {
|
|
||||||
delete process.env.OPENCLAW_BUNDLED_SKILLS_DIR;
|
|
||||||
} else {
|
|
||||||
process.env.OPENCLAW_BUNDLED_SKILLS_DIR = originalBundled;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("filters install options by OS", async () => {
|
it("filters install options by OS", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user