mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
test: manage workshop state fixtures
This commit is contained in:
@@ -3,12 +3,15 @@ import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { Command } from "commander";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import {
|
||||
createOpenClawTestState,
|
||||
type OpenClawTestState,
|
||||
} from "../test-utils/openclaw-test-state.js";
|
||||
import { createTrackedTempDirs } from "../test-utils/tracked-temp-dirs.js";
|
||||
import { registerSkillsCli } from "./skills-cli.js";
|
||||
|
||||
const tempDirs = createTrackedTempDirs();
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
let testState: OpenClawTestState;
|
||||
let stateDir = "";
|
||||
|
||||
const mocks = vi.hoisted(() => {
|
||||
@@ -88,10 +91,12 @@ describe("skills workshop cli", () => {
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]);
|
||||
testState = await createOpenClawTestState({
|
||||
layout: "state-only",
|
||||
prefix: "openclaw-skills-cli-workshop-state-",
|
||||
});
|
||||
mocks.workspaceDir = await tempDirs.make("openclaw-skills-cli-workshop-");
|
||||
stateDir = await tempDirs.make("openclaw-skills-cli-workshop-state-");
|
||||
process.env.OPENCLAW_STATE_DIR = stateDir;
|
||||
stateDir = testState.stateDir;
|
||||
mocks.runtimeStdout.length = 0;
|
||||
mocks.runtimeErrors.length = 0;
|
||||
mocks.defaultRuntime.log.mockClear();
|
||||
@@ -102,7 +107,7 @@ describe("skills workshop cli", () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
envSnapshot.restore();
|
||||
await testState.cleanup();
|
||||
await tempDirs.cleanup();
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { captureEnv } from "../../test-utils/env.js";
|
||||
import {
|
||||
createOpenClawTestState,
|
||||
type OpenClawTestState,
|
||||
} from "../../test-utils/openclaw-test-state.js";
|
||||
import { createTrackedTempDirs } from "../../test-utils/tracked-temp-dirs.js";
|
||||
import { buildWorkspaceSkillStatus } from "../discovery/status.js";
|
||||
import {
|
||||
@@ -25,17 +28,19 @@ import {
|
||||
import { readSkillProposalManifest, resolveProposalDraftPath } from "./store.js";
|
||||
|
||||
const tempDirs = createTrackedTempDirs();
|
||||
let envSnapshot: ReturnType<typeof captureEnv>;
|
||||
let testState: OpenClawTestState;
|
||||
let stateDir = "";
|
||||
|
||||
beforeEach(async () => {
|
||||
envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]);
|
||||
stateDir = await tempDirs.make("openclaw-skill-workshop-state-");
|
||||
process.env.OPENCLAW_STATE_DIR = stateDir;
|
||||
testState = await createOpenClawTestState({
|
||||
layout: "state-only",
|
||||
prefix: "openclaw-skill-workshop-state-",
|
||||
});
|
||||
stateDir = testState.stateDir;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
envSnapshot.restore();
|
||||
await testState.cleanup();
|
||||
resetSkillsRefreshStateForTest();
|
||||
await tempDirs.cleanup();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user