mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
29 lines
893 B
TypeScript
29 lines
893 B
TypeScript
import { vi } from "vitest";
|
|
import type * as SessionWriteLockModule from "../agents/session-write-lock.js";
|
|
|
|
type SessionWriteLockModuleShape = typeof SessionWriteLockModule;
|
|
|
|
export async function buildSessionWriteLockModuleMock(
|
|
loadActual: () => Promise<SessionWriteLockModuleShape>,
|
|
acquireSessionWriteLock: SessionWriteLockModuleShape["acquireSessionWriteLock"],
|
|
): Promise<SessionWriteLockModuleShape> {
|
|
const original = await loadActual();
|
|
return {
|
|
...original,
|
|
acquireSessionWriteLock,
|
|
};
|
|
}
|
|
|
|
export function resetModulesWithSessionWriteLockDoMock(
|
|
modulePath: string,
|
|
acquireSessionWriteLock: SessionWriteLockModuleShape["acquireSessionWriteLock"],
|
|
): void {
|
|
vi.resetModules();
|
|
vi.doMock(modulePath, () =>
|
|
buildSessionWriteLockModuleMock(
|
|
() => vi.importActual<SessionWriteLockModuleShape>(modulePath),
|
|
acquireSessionWriteLock,
|
|
),
|
|
);
|
|
}
|