test(tooling): deduplicate updater deployment fixtures (#124304)

This commit is contained in:
Peter Steinberger
2026-08-15 16:49:22 -07:00
committed by GitHub
parent bf4ec4b58a
commit 5626a79cc8
+25 -42
View File
@@ -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(