mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
test(telegram): keep session support inside package
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import {
|
||||
clearRuntimeConfigSnapshot,
|
||||
@@ -10,11 +11,38 @@ import {
|
||||
updateSessionStore,
|
||||
} from "openclaw/plugin-sdk/config-runtime";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
import { createSuiteTempRootTracker } from "../../../src/test-helpers/temp-dir.js";
|
||||
import { buildTelegramMessageContextForTest } from "./bot-message-context.test-harness.js";
|
||||
|
||||
const TELEGRAM_DIRECT_KEY = "agent:main:telegram:direct:7463849194";
|
||||
|
||||
function createSuiteTempRootTracker(params: { prefix: string }) {
|
||||
let root: string | undefined;
|
||||
const children: string[] = [];
|
||||
return {
|
||||
async setup() {
|
||||
root = await fs.mkdtemp(path.join(os.tmpdir(), params.prefix));
|
||||
},
|
||||
async make(name: string) {
|
||||
if (!root) {
|
||||
throw new Error("temp root not initialized");
|
||||
}
|
||||
const child = path.join(root, name);
|
||||
await fs.mkdir(child, { recursive: true });
|
||||
children.push(child);
|
||||
return child;
|
||||
},
|
||||
async cleanup() {
|
||||
await Promise.all(
|
||||
children.splice(0).map((child) => fs.rm(child, { force: true, recursive: true })),
|
||||
);
|
||||
if (root) {
|
||||
await fs.rm(root, { force: true, recursive: true });
|
||||
root = undefined;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("Telegram direct session recreation after delete", () => {
|
||||
const suiteRootTracker = createSuiteTempRootTracker({
|
||||
prefix: "openclaw-telegram-context-recreate-",
|
||||
|
||||
Reference in New Issue
Block a user