refactor(test): dedupe temp workspace setup in skills load entries e2e
This commit is contained in:
@@ -1,11 +1,25 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { loadWorkspaceSkillEntries } from "./skills.js";
|
||||
|
||||
async function setupWorkspaceWithProsePlugin() {
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
async function createTempWorkspaceDir() {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
||||
tempDirs.push(workspaceDir);
|
||||
return workspaceDir;
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(
|
||||
tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })),
|
||||
);
|
||||
});
|
||||
|
||||
async function setupWorkspaceWithProsePlugin() {
|
||||
const workspaceDir = await createTempWorkspaceDir();
|
||||
const managedDir = path.join(workspaceDir, ".managed");
|
||||
const bundledDir = path.join(workspaceDir, ".bundled");
|
||||
const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose");
|
||||
@@ -36,7 +50,7 @@ async function setupWorkspaceWithProsePlugin() {
|
||||
|
||||
describe("loadWorkspaceSkillEntries", () => {
|
||||
it("handles an empty managed skills dir without throwing", async () => {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
||||
const workspaceDir = await createTempWorkspaceDir();
|
||||
const managedDir = path.join(workspaceDir, ".managed");
|
||||
await fs.mkdir(managedDir, { recursive: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user