mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
test: consolidate OpenClaw test state fixtures (#113576)
* test: consolidate OpenClaw test state fixtures * test(plugin-sdk): expose isolated test state Promote the isolated OpenClaw test-state lifecycle through a narrow published Plugin SDK subpath so extension tests no longer import private core helpers. This intentional SDK surface addition is maintainer-approved. * test: use SDK test-state seam in extensions Route bundled extension suites through the focused repo-local Plugin SDK test-state entrypoint and remove the Codex projector harness exports made stale by fixture consolidation. Keep the seam out of production builds and published package artifacts while auditing its real consumers in the full-tree deadcode scan. * test(plugins): map test-state in package boundaries
This commit is contained in:
committed by
GitHub
parent
3d1369ff4f
commit
332006bc1f
@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { root as createFsSafeRoot } from "../infra/fs-safe.js";
|
||||
import { resetPluginStateStoreForTests } from "../plugin-state/plugin-state-store.js";
|
||||
import { clearMemoryPluginState } from "../plugins/memory-state.test-fixtures.js";
|
||||
import { createOpenClawTestState } from "../test-utils/openclaw-test-state.js";
|
||||
import { listMemoryHostPublicArtifacts } from "./memory-host-core.js";
|
||||
import {
|
||||
memoryHostEventExportOwnerContent,
|
||||
@@ -103,9 +104,11 @@ describe("memory host event export recovery", () => {
|
||||
});
|
||||
|
||||
it("finishes an inode-owned empty event export after interruption", async () => {
|
||||
const fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-host-inode-owner-"));
|
||||
const stateDir = path.join(fixtureRoot, "state");
|
||||
const workspaceDir = path.join(fixtureRoot, "workspace");
|
||||
const openClawState = await createOpenClawTestState({
|
||||
layout: "state-only",
|
||||
prefix: "memory-host-inode-owner-",
|
||||
});
|
||||
const { stateDir, workspaceDir } = openClawState;
|
||||
const event = {
|
||||
type: "memory.recall.recorded" as const,
|
||||
timestamp: "2026-05-18T12:00:00.000Z",
|
||||
@@ -114,8 +117,6 @@ describe("memory host event export recovery", () => {
|
||||
results: [],
|
||||
};
|
||||
try {
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
await fs.mkdir(workspaceDir);
|
||||
await appendMemoryHostEvent(workspaceDir, event);
|
||||
const stateHash = createHash("sha256")
|
||||
.update(await fs.realpath(stateDir))
|
||||
@@ -165,14 +166,16 @@ describe("memory host event export recovery", () => {
|
||||
});
|
||||
expect(owner.pendingContentSha256).toBeUndefined();
|
||||
} finally {
|
||||
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
||||
await openClawState.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not claim an empty export after exclusive-create interruption", async () => {
|
||||
const fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-host-empty-export-"));
|
||||
const stateDir = path.join(fixtureRoot, "state");
|
||||
const workspaceDir = path.join(fixtureRoot, "workspace");
|
||||
const openClawState = await createOpenClawTestState({
|
||||
layout: "state-only",
|
||||
prefix: "memory-host-empty-export-",
|
||||
});
|
||||
const { stateDir, workspaceDir } = openClawState;
|
||||
const event = {
|
||||
type: "memory.recall.recorded" as const,
|
||||
timestamp: "2026-05-18T12:00:00.000Z",
|
||||
@@ -181,8 +184,6 @@ describe("memory host event export recovery", () => {
|
||||
results: [],
|
||||
};
|
||||
try {
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
await fs.mkdir(workspaceDir);
|
||||
await appendMemoryHostEvent(workspaceDir, event);
|
||||
const stateHash = createHash("sha256")
|
||||
.update(await fs.realpath(stateDir))
|
||||
@@ -217,7 +218,7 @@ describe("memory host event export recovery", () => {
|
||||
expect(listed.some((artifact) => artifact.kind === "event-log")).toBe(false);
|
||||
await expect(fs.readFile(exportPath, "utf8")).resolves.toBe("");
|
||||
} finally {
|
||||
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
||||
await openClawState.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user