mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 00:30:23 +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();
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
|
||||
installGatewayTestHooks({ scope: "suite" });
|
||||
|
||||
const CONFIG_SECRETREF_RPC_TIMEOUT_MS = 20_000;
|
||||
|
||||
let startedServer: Awaited<ReturnType<typeof startServerWithClient>> | null = null;
|
||||
let sharedTempRoot: string;
|
||||
|
||||
@@ -90,6 +92,7 @@ describe("gateway config methods", () => {
|
||||
raw: JSON.stringify(nextConfig, null, 2),
|
||||
baseHash: current.payload?.hash,
|
||||
},
|
||||
CONFIG_SECRETREF_RPC_TIMEOUT_MS,
|
||||
);
|
||||
expect(res.ok).toBe(false);
|
||||
expect(res.error?.message ?? "").toContain("active SecretRef resolution failed");
|
||||
@@ -311,6 +314,7 @@ describe("gateway config methods", () => {
|
||||
}),
|
||||
baseHash: beforeHash,
|
||||
},
|
||||
CONFIG_SECRETREF_RPC_TIMEOUT_MS,
|
||||
);
|
||||
expect(res.ok).toBe(false);
|
||||
expect(res.error?.message ?? "").toContain("active SecretRef resolution failed");
|
||||
|
||||
Reference in New Issue
Block a user