mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:18:28 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
@@ -18,6 +18,21 @@ import { getShellPathFromLoginShell, resetShellPathCacheForTests } from "./shell
|
||||
import { listTailnetAddresses } from "./tailnet.js";
|
||||
|
||||
describe("infra runtime", () => {
|
||||
function setupRestartSignalSuite() {
|
||||
beforeEach(() => {
|
||||
__testing.resetSigusr1State();
|
||||
vi.useFakeTimers();
|
||||
vi.spyOn(process, "kill").mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await vi.runOnlyPendingTimersAsync();
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
__testing.resetSigusr1State();
|
||||
});
|
||||
}
|
||||
|
||||
describe("ensureBinary", () => {
|
||||
it("passes through when binary exists", async () => {
|
||||
const exec: typeof runExec = vi.fn().mockResolvedValue({
|
||||
@@ -69,18 +84,7 @@ describe("infra runtime", () => {
|
||||
});
|
||||
|
||||
describe("restart authorization", () => {
|
||||
beforeEach(() => {
|
||||
__testing.resetSigusr1State();
|
||||
vi.useFakeTimers();
|
||||
vi.spyOn(process, "kill").mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await vi.runOnlyPendingTimersAsync();
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
__testing.resetSigusr1State();
|
||||
});
|
||||
setupRestartSignalSuite();
|
||||
|
||||
it("authorizes exactly once when scheduled restart emits", async () => {
|
||||
expect(consumeGatewaySigusr1RestartAuthorization()).toBe(false);
|
||||
@@ -124,18 +128,7 @@ describe("infra runtime", () => {
|
||||
});
|
||||
|
||||
describe("pre-restart deferral check", () => {
|
||||
beforeEach(() => {
|
||||
__testing.resetSigusr1State();
|
||||
vi.useFakeTimers();
|
||||
vi.spyOn(process, "kill").mockImplementation(() => true);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await vi.runOnlyPendingTimersAsync();
|
||||
vi.useRealTimers();
|
||||
vi.restoreAllMocks();
|
||||
__testing.resetSigusr1State();
|
||||
});
|
||||
setupRestartSignalSuite();
|
||||
|
||||
it("emits SIGUSR1 immediately when no deferral check is registered", async () => {
|
||||
const emitSpy = vi.spyOn(process, "emit");
|
||||
|
||||
Reference in New Issue
Block a user