mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 22:41:36 +00:00
perf(test): slim raw-body directive integration
This commit is contained in:
@@ -195,6 +195,47 @@ describe("initSessionState RawBody", () => {
|
||||
|
||||
expect(result.triggerBodyNormalized).toBe("/status");
|
||||
});
|
||||
|
||||
it("uses the default per-agent sessions store when config store is unset", async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-session-store-default-"));
|
||||
const stateDir = path.join(root, ".openclaw");
|
||||
const agentId = "worker1";
|
||||
const sessionKey = `agent:${agentId}:telegram:12345`;
|
||||
const sessionId = "sess-worker-1";
|
||||
const sessionFile = path.join(stateDir, "agents", agentId, "sessions", `${sessionId}.jsonl`);
|
||||
const storePath = path.join(stateDir, "agents", agentId, "sessions", "sessions.json");
|
||||
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
|
||||
try {
|
||||
await fs.mkdir(path.dirname(storePath), { recursive: true });
|
||||
await saveSessionStore(storePath, {
|
||||
[sessionKey]: {
|
||||
sessionId,
|
||||
sessionFile,
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
});
|
||||
|
||||
const cfg = {} as OpenClawConfig;
|
||||
const result = await initSessionState({
|
||||
ctx: {
|
||||
Body: "hello",
|
||||
ChatType: "direct",
|
||||
Provider: "telegram",
|
||||
Surface: "telegram",
|
||||
SessionKey: sessionKey,
|
||||
},
|
||||
cfg,
|
||||
commandAuthorized: true,
|
||||
});
|
||||
|
||||
expect(result.sessionEntry.sessionId).toBe(sessionId);
|
||||
expect(result.sessionEntry.sessionFile).toBe(sessionFile);
|
||||
expect(result.storePath).toBe(storePath);
|
||||
} finally {
|
||||
vi.unstubAllEnvs();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("initSessionState reset policy", () => {
|
||||
|
||||
Reference in New Issue
Block a user