Matrix: trim storage test import churn

This commit is contained in:
Gustavo Madeira Santana 2026-03-31 07:07:30 -04:00
parent 225dfe0094
commit 2bdf2fbf14
No known key found for this signature in database
2 changed files with 9 additions and 23 deletions

View File

@ -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) => ({

View File

@ -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();