fix(update): honor update.channel for update.run

This commit is contained in:
Peter Steinberger
2026-02-03 17:57:44 -08:00
parent 61a7fc5e0e
commit bbe9cb3022
5 changed files with 98 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ vi.mock("../infra/update-runner.js", () => ({
})),
}));
import { writeConfigFile } from "../config/config.js";
import { runGatewayUpdate } from "../infra/update-runner.js";
import { sleep } from "../utils.js";
import {
connectOk,
@@ -193,6 +195,37 @@ describe("gateway update.run", () => {
process.off("SIGUSR1", sigusr1);
}
});
test("uses configured update channel", async () => {
const sigusr1 = vi.fn();
process.on("SIGUSR1", sigusr1);
try {
await writeConfigFile({ update: { channel: "beta" } });
const updateMock = vi.mocked(runGatewayUpdate);
updateMock.mockClear();
const id = "req-update-channel";
ws.send(
JSON.stringify({
type: "req",
id,
method: "update.run",
params: {
restartDelayMs: 0,
},
}),
);
const res = await onceMessage<{ ok: boolean; payload?: unknown }>(
ws,
(o) => o.type === "res" && o.id === id,
);
expect(res.ok).toBe(true);
expect(updateMock.mock.calls[0]?.[0]?.channel).toBe("beta");
} finally {
process.off("SIGUSR1", sigusr1);
}
});
});
describe("gateway node command allowlist", () => {