mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:40:43 +00:00
test: share daemon scheduled repair helper
This commit is contained in:
@@ -187,14 +187,14 @@ describe("maybeRepairGatewayDaemon", () => {
|
||||
});
|
||||
}
|
||||
|
||||
it("skips restart verification when a running service restart is only scheduled", async () => {
|
||||
async function runScheduledGatewayRepair(confirmMessage: string) {
|
||||
setPlatform("linux");
|
||||
service.restart.mockResolvedValueOnce({ outcome: "scheduled" });
|
||||
|
||||
await maybeRepairGatewayDaemon({
|
||||
cfg: { gateway: {} },
|
||||
runtime: { log: vi.fn(), error: vi.fn(), exit: vi.fn() },
|
||||
prompter: createPrompter((message) => message === "Restart gateway service now?"),
|
||||
prompter: createPrompter((message) => message === confirmMessage),
|
||||
options: { deep: false },
|
||||
gatewayDetailsMessage: "details",
|
||||
healthOk: false,
|
||||
@@ -207,29 +207,15 @@ describe("maybeRepairGatewayDaemon", () => {
|
||||
);
|
||||
expect(sleep).not.toHaveBeenCalled();
|
||||
expect(healthCommand).not.toHaveBeenCalled();
|
||||
}
|
||||
|
||||
it("skips restart verification when a running service restart is only scheduled", async () => {
|
||||
await runScheduledGatewayRepair("Restart gateway service now?");
|
||||
});
|
||||
|
||||
it("skips start verification when a stopped service start is only scheduled", async () => {
|
||||
setPlatform("linux");
|
||||
service.readRuntime.mockResolvedValue({ status: "stopped" });
|
||||
service.restart.mockResolvedValueOnce({ outcome: "scheduled" });
|
||||
|
||||
await maybeRepairGatewayDaemon({
|
||||
cfg: { gateway: {} },
|
||||
runtime: { log: vi.fn(), error: vi.fn(), exit: vi.fn() },
|
||||
prompter: createPrompter((message) => message === "Start gateway service now?"),
|
||||
options: { deep: false },
|
||||
gatewayDetailsMessage: "details",
|
||||
healthOk: false,
|
||||
});
|
||||
|
||||
expect(service.restart).toHaveBeenCalledTimes(1);
|
||||
expect(note).toHaveBeenCalledWith(
|
||||
"restart scheduled, gateway will restart momentarily",
|
||||
"Gateway",
|
||||
);
|
||||
expect(sleep).not.toHaveBeenCalled();
|
||||
expect(healthCommand).not.toHaveBeenCalled();
|
||||
await runScheduledGatewayRepair("Start gateway service now?");
|
||||
});
|
||||
|
||||
it("skips gateway install during non-interactive update repairs", async () => {
|
||||
|
||||
Reference in New Issue
Block a user