From f8e47ee32afbc81533bef30c79425589c8bba355 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 8 May 2026 09:50:53 +0100 Subject: [PATCH] test: remove dead session store fixtures --- .../reply/get-reply.fast-path.test.ts | 57 ++++++++++--------- .../server-methods/tools-effective.test.ts | 1 - 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/auto-reply/reply/get-reply.fast-path.test.ts b/src/auto-reply/reply/get-reply.fast-path.test.ts index dce4d111db6..298549f3748 100644 --- a/src/auto-reply/reply/get-reply.fast-path.test.ts +++ b/src/auto-reply/reply/get-reply.fast-path.test.ts @@ -3,6 +3,8 @@ import os from "node:os"; import path from "node:path"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../../config/config.js"; +import { upsertSessionEntry } from "../../config/sessions/store.js"; +import { closeOpenClawAgentDatabasesForTest } from "../../state/openclaw-agent-db.js"; import { buildFastReplyCommandContext, initFastReplySessionState, @@ -59,6 +61,7 @@ describe("getReplyFromConfig fast test bootstrap", () => { }); afterEach(() => { + closeOpenClawAgentDatabasesForTest(); vi.unstubAllEnvs(); }); @@ -79,7 +82,7 @@ describe("getReplyFromConfig fast test bootstrap", () => { }, }, channels: { telegram: { allowFrom: ["*"] } }, - session: { store: path.join(home, "sessions.json") }, + session: {}, } as OpenClawConfig); await expect(getReplyFromConfig(buildGetReplyCtx(), undefined, cfg)).resolves.toEqual({ @@ -120,7 +123,9 @@ describe("getReplyFromConfig fast test bootstrap", () => { }); it("marks configs through withFastReplyConfig()", async () => { - const cfg = withFastReplyConfig({ session: { store: "/tmp/sessions.json" } } as OpenClawConfig); + const cfg = withFastReplyConfig({ + session: {}, + } as OpenClawConfig); await expect(getReplyFromConfig(buildGetReplyCtx(), undefined, cfg)).resolves.toEqual({ text: "ok", @@ -217,7 +222,9 @@ describe("getReplyFromConfig fast test bootstrap", () => { CommandSource: "native", CommandTargetSessionKey: "agent:main:main", }), - cfg: { session: { store: "/tmp/sessions.json" } } as OpenClawConfig, + cfg: { + session: {}, + } as OpenClawConfig, agentId: "main", commandAuthorized: true, workspaceDir: "/tmp/workspace", @@ -253,18 +260,16 @@ describe("getReplyFromConfig fast test bootstrap", () => { it("keeps the existing session for /reset newline soft during fast bootstrap", async () => { const home = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-fast-reset-newline-soft-")); - const storePath = path.join(home, "sessions.json"); + vi.stubEnv("OPENCLAW_STATE_DIR", path.join(home, ".openclaw")); const sessionKey = "agent:main:telegram:123"; - await fs.writeFile( - storePath, - JSON.stringify({ - [sessionKey]: { - sessionId: "existing-fast-reset-newline-soft", - updatedAt: Date.now(), - }, - }), - "utf8", - ); + upsertSessionEntry({ + agentId: "main", + sessionKey, + entry: { + sessionId: "existing-fast-reset-newline-soft", + updatedAt: Date.now(), + }, + }); const result = initFastReplySessionState({ ctx: buildGetReplyCtx({ @@ -273,7 +278,7 @@ describe("getReplyFromConfig fast test bootstrap", () => { CommandBody: "/reset \nsoft", SessionKey: sessionKey, }), - cfg: { session: { store: storePath } } as OpenClawConfig, + cfg: { session: {} } as OpenClawConfig, agentId: "main", commandAuthorized: true, workspaceDir: home, @@ -286,18 +291,16 @@ describe("getReplyFromConfig fast test bootstrap", () => { it("keeps the existing session for /reset: soft during fast bootstrap", async () => { const home = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-fast-reset-colon-soft-")); - const storePath = path.join(home, "sessions.json"); + vi.stubEnv("OPENCLAW_STATE_DIR", path.join(home, ".openclaw")); const sessionKey = "agent:main:telegram:123"; - await fs.writeFile( - storePath, - JSON.stringify({ - [sessionKey]: { - sessionId: "existing-fast-reset-colon-soft", - updatedAt: Date.now(), - }, - }), - "utf8", - ); + upsertSessionEntry({ + agentId: "main", + sessionKey, + entry: { + sessionId: "existing-fast-reset-colon-soft", + updatedAt: Date.now(), + }, + }); const result = initFastReplySessionState({ ctx: buildGetReplyCtx({ @@ -306,7 +309,7 @@ describe("getReplyFromConfig fast test bootstrap", () => { CommandBody: "/reset: soft", SessionKey: sessionKey, }), - cfg: { session: { store: storePath } } as OpenClawConfig, + cfg: { session: {} } as OpenClawConfig, agentId: "main", commandAuthorized: true, workspaceDir: home, diff --git a/src/gateway/server-methods/tools-effective.test.ts b/src/gateway/server-methods/tools-effective.test.ts index 86361f9319a..ee782c3d6b2 100644 --- a/src/gateway/server-methods/tools-effective.test.ts +++ b/src/gateway/server-methods/tools-effective.test.ts @@ -131,7 +131,6 @@ describe("tools.effective handler", () => { canonicalKey: "missing-session", entry: undefined, legacyKey: undefined, - storePath: "/tmp/sessions.json", } as never); const { respond, invoke } = createInvokeParams({ sessionKey: "missing-session" }); await invoke();