mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 21:31:26 +00:00
Matrix: trim storage test import churn
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveMatrixAccountStorageRoot } from "../../../runtime-api.js";
|
||||
import { installMatrixTestRuntime } from "../../test-runtime.js";
|
||||
import {
|
||||
@@ -39,12 +39,10 @@ vi.mock("../../../../../src/infra/backup-create.js", async (importOriginal) => {
|
||||
createBackupArchive: (params: unknown) => createBackupArchiveMock(params),
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("./migration-snapshot.runtime.js", () => ({
|
||||
maybeCreateMatrixMigrationSnapshot: (params: unknown) =>
|
||||
maybeCreateMatrixMigrationSnapshotMock(params),
|
||||
}));
|
||||
|
||||
describe("matrix client storage paths", () => {
|
||||
const tempDirs: string[] = [];
|
||||
const defaultStorageAuth = {
|
||||
@@ -53,8 +51,6 @@ describe("matrix client storage paths", () => {
|
||||
accessToken: "secret-token",
|
||||
};
|
||||
|
||||
beforeEach(() => {});
|
||||
|
||||
afterEach(() => {
|
||||
createBackupArchiveMock.mockReset();
|
||||
createBackupArchiveMock.mockImplementation(async (_params: unknown) => ({
|
||||
|
||||
@@ -4,6 +4,14 @@ import path from "node:path";
|
||||
import { getSessionBindingService, __testing } from "openclaw/plugin-sdk/conversation-runtime";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { PluginRuntime } from "../../runtime-api.js";
|
||||
import { setMatrixRuntime } from "../runtime.js";
|
||||
import { resolveMatrixStateFilePath, resolveMatrixStoragePaths } from "./client/storage.js";
|
||||
import {
|
||||
createMatrixThreadBindingManager,
|
||||
resetMatrixThreadBindingsForTests,
|
||||
setMatrixThreadBindingIdleTimeoutBySessionKey,
|
||||
setMatrixThreadBindingMaxAgeBySessionKey,
|
||||
} from "./thread-bindings.js";
|
||||
|
||||
const sendMessageMatrixMock = vi.hoisted(() =>
|
||||
vi.fn(async (_to: string, _message: string, opts?: { threadId?: string }) => ({
|
||||
@@ -22,14 +30,6 @@ vi.mock("./send.js", async () => {
|
||||
};
|
||||
});
|
||||
|
||||
let resolveMatrixStateFilePath: typeof import("./client/storage.js").resolveMatrixStateFilePath;
|
||||
let resolveMatrixStoragePaths: typeof import("./client/storage.js").resolveMatrixStoragePaths;
|
||||
let createMatrixThreadBindingManager: typeof import("./thread-bindings.js").createMatrixThreadBindingManager;
|
||||
let resetMatrixThreadBindingsForTests: typeof import("./thread-bindings.js").resetMatrixThreadBindingsForTests;
|
||||
let setMatrixThreadBindingIdleTimeoutBySessionKey: typeof import("./thread-bindings.js").setMatrixThreadBindingIdleTimeoutBySessionKey;
|
||||
let setMatrixThreadBindingMaxAgeBySessionKey: typeof import("./thread-bindings.js").setMatrixThreadBindingMaxAgeBySessionKey;
|
||||
let setMatrixRuntime: typeof import("../runtime.js").setMatrixRuntime;
|
||||
|
||||
describe("matrix thread bindings", () => {
|
||||
let stateDir: string;
|
||||
const auth = {
|
||||
@@ -101,16 +101,6 @@ describe("matrix thread bindings", () => {
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ setMatrixRuntime } = await import("../runtime.js"));
|
||||
({ resolveMatrixStateFilePath, resolveMatrixStoragePaths } =
|
||||
await import("./client/storage.js"));
|
||||
({
|
||||
createMatrixThreadBindingManager,
|
||||
resetMatrixThreadBindingsForTests,
|
||||
setMatrixThreadBindingIdleTimeoutBySessionKey,
|
||||
setMatrixThreadBindingMaxAgeBySessionKey,
|
||||
} = await import("./thread-bindings.js"));
|
||||
stateDir = await fs.mkdtemp(path.join(os.tmpdir(), "matrix-thread-bindings-"));
|
||||
__testing.resetSessionBindingAdaptersForTests();
|
||||
resetMatrixThreadBindingsForTests();
|
||||
|
||||
Reference in New Issue
Block a user