mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-28 14:33:38 +00:00
chore(deadcode): remove stale session test facades
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { setActivePluginRegistry } from "../../plugins/runtime.js";
|
||||
import { createSessionConversationTestRegistry } from "../../test-utils/session-conversation-registry.js";
|
||||
import { parseSessionThreadInfo } from "./thread-info.js";
|
||||
import type { SessionEntry } from "./types.js";
|
||||
|
||||
const storeState = vi.hoisted(() => {
|
||||
@@ -37,7 +38,6 @@ vi.mock("./targets.js", () => ({
|
||||
}));
|
||||
|
||||
let extractDeliveryInfo: typeof import("./delivery-info.js").extractDeliveryInfo;
|
||||
let parseSessionThreadInfo: typeof import("./delivery-info.js").parseSessionThreadInfo;
|
||||
|
||||
const buildEntry = (deliveryContext: SessionEntry["deliveryContext"]): SessionEntry => ({
|
||||
sessionId: "session-1",
|
||||
@@ -46,7 +46,7 @@ const buildEntry = (deliveryContext: SessionEntry["deliveryContext"]): SessionEn
|
||||
});
|
||||
|
||||
beforeAll(async () => {
|
||||
({ extractDeliveryInfo, parseSessionThreadInfo } = await import("./delivery-info.js"));
|
||||
({ extractDeliveryInfo } = await import("./delivery-info.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -19,7 +19,6 @@ import { readSessionStoreSnapshot } from "./store.js";
|
||||
import { resolveAllAgentSessionStoreTargetsSync } from "./targets.js";
|
||||
import { parseSessionThreadInfo } from "./thread-info.js";
|
||||
import type { SessionEntry } from "./types.js";
|
||||
export { parseSessionThreadInfo };
|
||||
|
||||
function hasRoutableDeliveryContext(context?: {
|
||||
channel?: string;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
// Session store writer tests cover serialized session writes and cleanup.
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createDeferred } from "../../test-utils/deferred.js";
|
||||
import {
|
||||
clearSessionStoreCacheForTest,
|
||||
getSessionStoreWriterQueueSizeForTest,
|
||||
withSessionStoreWriterForTest,
|
||||
} from "./store.js";
|
||||
import { runExclusiveSessionStoreWrite } from "./store-writer.js";
|
||||
import { clearSessionStoreCacheForTest, getSessionStoreWriterQueueSizeForTest } from "./store.js";
|
||||
|
||||
describe("session store writer", () => {
|
||||
afterEach(() => {
|
||||
@@ -18,13 +15,13 @@ describe("session store writer", () => {
|
||||
const releaseFirst = createDeferred();
|
||||
const order: string[] = [];
|
||||
|
||||
const first = withSessionStoreWriterForTest(storePath, async () => {
|
||||
const first = runExclusiveSessionStoreWrite(storePath, async () => {
|
||||
order.push("first:start");
|
||||
firstStarted.resolve();
|
||||
await releaseFirst.promise;
|
||||
order.push("first:end");
|
||||
});
|
||||
const second = withSessionStoreWriterForTest(storePath, async () => {
|
||||
const second = runExclusiveSessionStoreWrite(storePath, async () => {
|
||||
order.push("second");
|
||||
});
|
||||
|
||||
@@ -40,7 +37,7 @@ describe("session store writer", () => {
|
||||
});
|
||||
|
||||
it("rejects empty store paths before enqueuing work", async () => {
|
||||
await expect(withSessionStoreWriterForTest("", async () => undefined)).rejects.toThrow(
|
||||
await expect(runExclusiveSessionStoreWrite("", async () => undefined)).rejects.toThrow(
|
||||
/storePath must be a non-empty string/,
|
||||
);
|
||||
expect(getSessionStoreWriterQueueSizeForTest()).toBe(0);
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
import { runQueuedStoreWrite } from "../../shared/store-writer-queue.js";
|
||||
import { WRITER_QUEUES } from "./store-writer-state.js";
|
||||
|
||||
/** Runs a callback under the same per-store writer queue used in production. */
|
||||
export async function withSessionStoreWriterForTest<T>(
|
||||
storePath: string,
|
||||
fn: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
return await runExclusiveSessionStoreWrite(storePath, fn);
|
||||
}
|
||||
|
||||
export async function runExclusiveSessionStoreWrite<T>(
|
||||
storePath: string,
|
||||
fn: () => Promise<T>,
|
||||
|
||||
@@ -82,7 +82,6 @@ export {
|
||||
drainSessionStoreWriterQueuesForTest,
|
||||
getSessionStoreWriterQueueSizeForTest,
|
||||
} from "./store-writer-state.js";
|
||||
export { withSessionStoreWriterForTest } from "./store-writer.js";
|
||||
export {
|
||||
loadSessionStore,
|
||||
readSessionEntries,
|
||||
|
||||
@@ -4,10 +4,10 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { resetSessionWriteLockStateForTest } from "../agents/session-write-lock.js";
|
||||
import { runExclusiveSessionStoreWrite } from "../config/sessions/store-writer.js";
|
||||
import {
|
||||
clearSessionStoreCacheForTest,
|
||||
getSessionStoreWriterQueueSizeForTest,
|
||||
withSessionStoreWriterForTest,
|
||||
} from "../config/sessions/store.js";
|
||||
import { resetFileLockStateForTest } from "../infra/file-lock.js";
|
||||
import { createDeferred } from "./deferred.js";
|
||||
@@ -67,7 +67,7 @@ describe("cleanupSessionStateForTest", () => {
|
||||
});
|
||||
let running: Promise<void> | undefined;
|
||||
try {
|
||||
running = withSessionStoreWriterForTest(storePath, async () => {
|
||||
running = runExclusiveSessionStoreWrite(storePath, async () => {
|
||||
started.resolve();
|
||||
await release.promise;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user