Skip to content

Commit 39c3029

Browse files
committed
test(tooling): deduplicate updater deployment fixtures
1 parent 878236c commit 39c3029

1 file changed

Lines changed: 25 additions & 42 deletions

File tree

‎test/scripts/openclaw-live-updater.test.ts‎

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,28 @@ function managedTimeoutError() {
246246
return Object.assign(new Error("managed timeout"), { code: "ETIMEDOUT" });
247247
}
248248

249+
function createManagedLaunchAgentFixture(root: string, mirror: string) {
250+
const lockPath = path.join(root, "maintenance.lock");
251+
const plistPath = path.join(root, "ai.openclaw.gateway.plist");
252+
const entrypoint = path.join(mirror, "dist/index.js");
253+
writeFileSync(plistPath, "plist\n", { mode: 0o600 });
254+
return {
255+
lockPath,
256+
plistPath,
257+
deployment: {
258+
configPath: path.join(root, "openclaw.json"),
259+
entrypoint,
260+
entrypointIndex: 1,
261+
executable: process.execPath,
262+
invocationPrefix: [entrypoint],
263+
label: "ai.openclaw.gateway",
264+
plistPath,
265+
port: 18789,
266+
runtime: process.execPath,
267+
},
268+
};
269+
}
270+
249271
function createGatewaySuspensionCliStub(
250272
root: string,
251273
requestError: { code: string; message: string; retryable: boolean; type: string },
@@ -1859,20 +1881,7 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
18591881
test("recovers the previous service after a post-stop install timeout", async () => {
18601882
const { root, mirror } = makeFixture();
18611883
writeBuild(mirror);
1862-
const lockPath = path.join(root, "maintenance.lock");
1863-
const plistPath = path.join(root, "ai.openclaw.gateway.plist");
1864-
writeFileSync(plistPath, "plist\n", { mode: 0o600 });
1865-
const deployment = {
1866-
configPath: path.join(root, "openclaw.json"),
1867-
entrypoint: path.join(mirror, "dist/index.js"),
1868-
entrypointIndex: 1,
1869-
executable: process.execPath,
1870-
invocationPrefix: [path.join(mirror, "dist/index.js")],
1871-
label: "ai.openclaw.gateway",
1872-
plistPath,
1873-
port: 18789,
1874-
runtime: process.execPath,
1875-
};
1884+
const { deployment, lockPath, plistPath } = createManagedLaunchAgentFixture(root, mirror);
18761885
const events: string[] = [];
18771886

18781887
await expect(
@@ -1945,20 +1954,7 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
19451954
async () => {
19461955
const { root, mirror } = makeFixture();
19471956
writeBuild(mirror);
1948-
const lockPath = path.join(root, "maintenance.lock");
1949-
const plistPath = path.join(root, "ai.openclaw.gateway.plist");
1950-
writeFileSync(plistPath, "plist\n", { mode: 0o600 });
1951-
const deployment = {
1952-
configPath: path.join(root, "openclaw.json"),
1953-
entrypoint: path.join(mirror, "dist/index.js"),
1954-
entrypointIndex: 1,
1955-
executable: process.execPath,
1956-
invocationPrefix: [path.join(mirror, "dist/index.js")],
1957-
label: "ai.openclaw.gateway",
1958-
plistPath,
1959-
port: 18789,
1960-
runtime: process.execPath,
1961-
};
1957+
const { deployment, lockPath } = createManagedLaunchAgentFixture(root, mirror);
19621958
const blocker = spawn(process.execPath, ["-e", "setInterval(() => {}, 1_000)"], {
19631959
detached: true,
19641960
stdio: "ignore",
@@ -2048,20 +2044,7 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
20482044
test("retains a manual-recovery lock when Windows timeout cleanup is unverified", async () => {
20492045
const { root, mirror } = makeFixture();
20502046
writeBuild(mirror);
2051-
const lockPath = path.join(root, "maintenance.lock");
2052-
const plistPath = path.join(root, "ai.openclaw.gateway.plist");
2053-
writeFileSync(plistPath, "plist\n", { mode: 0o600 });
2054-
const deployment = {
2055-
configPath: path.join(root, "openclaw.json"),
2056-
entrypoint: path.join(mirror, "dist/index.js"),
2057-
entrypointIndex: 1,
2058-
executable: process.execPath,
2059-
invocationPrefix: [path.join(mirror, "dist/index.js")],
2060-
label: "ai.openclaw.gateway",
2061-
plistPath,
2062-
port: 18789,
2063-
runtime: process.execPath,
2064-
};
2047+
const { deployment, lockPath } = createManagedLaunchAgentFixture(root, mirror);
20652048
const events: string[] = [];
20662049

20672050
await expect(

0 commit comments

Comments
 (0)