From 5626a79cc836d95d236debd720a34fc2dcdcc685 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 15 Aug 2026 16:49:22 -0700 Subject: [PATCH] test(tooling): deduplicate updater deployment fixtures (#124304) --- test/scripts/openclaw-live-updater.test.ts | 67 ++++++++-------------- 1 file changed, 25 insertions(+), 42 deletions(-) diff --git a/test/scripts/openclaw-live-updater.test.ts b/test/scripts/openclaw-live-updater.test.ts index c224b3d003fa..3a3c9b10ff2e 100644 --- a/test/scripts/openclaw-live-updater.test.ts +++ b/test/scripts/openclaw-live-updater.test.ts @@ -246,6 +246,28 @@ function managedTimeoutError() { return Object.assign(new Error("managed timeout"), { code: "ETIMEDOUT" }); } +function createManagedLaunchAgentFixture(root: string, mirror: string) { + const lockPath = path.join(root, "maintenance.lock"); + const plistPath = path.join(root, "ai.openclaw.gateway.plist"); + const entrypoint = path.join(mirror, "dist/index.js"); + writeFileSync(plistPath, "plist\n", { mode: 0o600 }); + return { + lockPath, + plistPath, + deployment: { + configPath: path.join(root, "openclaw.json"), + entrypoint, + entrypointIndex: 1, + executable: process.execPath, + invocationPrefix: [entrypoint], + label: "ai.openclaw.gateway", + plistPath, + port: 18789, + runtime: process.execPath, + }, + }; +} + function createGatewaySuspensionCliStub( root: string, requestError: { code: string; message: string; retryable: boolean; type: string }, @@ -1859,20 +1881,7 @@ console.log(JSON.stringify({ ok: true, channels: {} })); test("recovers the previous service after a post-stop install timeout", async () => { const { root, mirror } = makeFixture(); writeBuild(mirror); - const lockPath = path.join(root, "maintenance.lock"); - const plistPath = path.join(root, "ai.openclaw.gateway.plist"); - writeFileSync(plistPath, "plist\n", { mode: 0o600 }); - const deployment = { - configPath: path.join(root, "openclaw.json"), - entrypoint: path.join(mirror, "dist/index.js"), - entrypointIndex: 1, - executable: process.execPath, - invocationPrefix: [path.join(mirror, "dist/index.js")], - label: "ai.openclaw.gateway", - plistPath, - port: 18789, - runtime: process.execPath, - }; + const { deployment, lockPath, plistPath } = createManagedLaunchAgentFixture(root, mirror); const events: string[] = []; await expect( @@ -1945,20 +1954,7 @@ console.log(JSON.stringify({ ok: true, channels: {} })); async () => { const { root, mirror } = makeFixture(); writeBuild(mirror); - const lockPath = path.join(root, "maintenance.lock"); - const plistPath = path.join(root, "ai.openclaw.gateway.plist"); - writeFileSync(plistPath, "plist\n", { mode: 0o600 }); - const deployment = { - configPath: path.join(root, "openclaw.json"), - entrypoint: path.join(mirror, "dist/index.js"), - entrypointIndex: 1, - executable: process.execPath, - invocationPrefix: [path.join(mirror, "dist/index.js")], - label: "ai.openclaw.gateway", - plistPath, - port: 18789, - runtime: process.execPath, - }; + const { deployment, lockPath } = createManagedLaunchAgentFixture(root, mirror); const blocker = spawn(process.execPath, ["-e", "setInterval(() => {}, 1_000)"], { detached: true, stdio: "ignore", @@ -2048,20 +2044,7 @@ console.log(JSON.stringify({ ok: true, channels: {} })); test("retains a manual-recovery lock when Windows timeout cleanup is unverified", async () => { const { root, mirror } = makeFixture(); writeBuild(mirror); - const lockPath = path.join(root, "maintenance.lock"); - const plistPath = path.join(root, "ai.openclaw.gateway.plist"); - writeFileSync(plistPath, "plist\n", { mode: 0o600 }); - const deployment = { - configPath: path.join(root, "openclaw.json"), - entrypoint: path.join(mirror, "dist/index.js"), - entrypointIndex: 1, - executable: process.execPath, - invocationPrefix: [path.join(mirror, "dist/index.js")], - label: "ai.openclaw.gateway", - plistPath, - port: 18789, - runtime: process.execPath, - }; + const { deployment, lockPath } = createManagedLaunchAgentFixture(root, mirror); const events: string[] = []; await expect(