mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 04:31:10 +00:00
fix(test): restore cli runtime mocks and gateway timeouts
This commit is contained in:
@@ -54,6 +54,33 @@ const { defaultRuntime, runtimeLogs, runtimeErrors, resetRuntimeCapture } =
|
||||
|
||||
export { runtimeErrors, runtimeLogs };
|
||||
|
||||
function restoreRuntimeCaptureMocks() {
|
||||
defaultRuntime.log.mockReset();
|
||||
defaultRuntime.log.mockImplementation((...args: unknown[]) => {
|
||||
runtimeLogs.push(args.map((value) => String(value)).join(" "));
|
||||
});
|
||||
|
||||
defaultRuntime.error.mockReset();
|
||||
defaultRuntime.error.mockImplementation((...args: unknown[]) => {
|
||||
runtimeErrors.push(args.map((value) => String(value)).join(" "));
|
||||
});
|
||||
|
||||
defaultRuntime.writeStdout.mockReset();
|
||||
defaultRuntime.writeStdout.mockImplementation((value: string) => {
|
||||
defaultRuntime.log(value.endsWith("\n") ? value.slice(0, -1) : value);
|
||||
});
|
||||
|
||||
defaultRuntime.writeJson.mockReset();
|
||||
defaultRuntime.writeJson.mockImplementation((value: unknown, space = 2) => {
|
||||
defaultRuntime.log(JSON.stringify(value, null, space > 0 ? space : undefined));
|
||||
});
|
||||
|
||||
defaultRuntime.exit.mockReset();
|
||||
defaultRuntime.exit.mockImplementation((code: number) => {
|
||||
throw new Error(`__exit__:${code}`);
|
||||
});
|
||||
}
|
||||
|
||||
vi.mock("../runtime.js", () => ({
|
||||
defaultRuntime,
|
||||
}));
|
||||
@@ -327,6 +354,7 @@ export function runPluginsCommand(argv: string[]) {
|
||||
|
||||
export function resetPluginsCliTestState() {
|
||||
resetRuntimeCapture();
|
||||
restoreRuntimeCaptureMocks();
|
||||
loadConfig.mockReset();
|
||||
readConfigFileSnapshot.mockReset();
|
||||
writeConfigFile.mockReset();
|
||||
|
||||
Reference in New Issue
Block a user