mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test(perf): avoid module reset churn in daemon lifecycle tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
type RestartHealthSnapshot = {
|
||||
healthy: boolean;
|
||||
@@ -56,8 +56,13 @@ vi.mock("./lifecycle-core.js", () => ({
|
||||
}));
|
||||
|
||||
describe("runDaemonRestart health checks", () => {
|
||||
let runDaemonRestart: (opts?: { json?: boolean }) => Promise<boolean>;
|
||||
|
||||
beforeAll(async () => {
|
||||
({ runDaemonRestart } = await import("./lifecycle.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetModules();
|
||||
service.readCommand.mockClear();
|
||||
service.restart.mockClear();
|
||||
runServiceRestart.mockClear();
|
||||
@@ -104,7 +109,6 @@ describe("runDaemonRestart health checks", () => {
|
||||
waitForGatewayHealthyRestart.mockResolvedValueOnce(unhealthy).mockResolvedValueOnce(healthy);
|
||||
terminateStaleGatewayPids.mockResolvedValue([1993]);
|
||||
|
||||
const { runDaemonRestart } = await import("./lifecycle.js");
|
||||
const result = await runDaemonRestart({ json: true });
|
||||
|
||||
expect(result).toBe(true);
|
||||
@@ -122,8 +126,6 @@ describe("runDaemonRestart health checks", () => {
|
||||
};
|
||||
waitForGatewayHealthyRestart.mockResolvedValue(unhealthy);
|
||||
|
||||
const { runDaemonRestart } = await import("./lifecycle.js");
|
||||
|
||||
await expect(runDaemonRestart({ json: true })).rejects.toMatchObject({
|
||||
message: "Gateway restart timed out after 60s waiting for health checks.",
|
||||
hints: ["openclaw gateway status --deep", "openclaw doctor"],
|
||||
|
||||
Reference in New Issue
Block a user