





















@@ -47,7 +47,7 @@ describe("gateway restart handoff", () => {
4747it("writes a supervisor handoff for an exited gateway process", () => {
4848const env = createHandoffEnv();
494950-const handoff = writeGatewayRestartHandoffSync({
50+const handoff = expectWrittenHandoff({
5151 env,
5252pid: 12_345,
5353processInstanceId: "gateway-instance-1",
@@ -57,23 +57,20 @@ describe("gateway restart handoff", () => {
5757createdAt: 1_000,
5858});
595960-expect(handoff).toMatchObject({
61-kind: GATEWAY_SUPERVISOR_RESTART_HANDOFF_KIND,
62-version: 1,
63-pid: 12_345,
64-processInstanceId: "gateway-instance-1",
65-reason: "plugin source changed",
66-source: "plugin-change",
67-restartKind: "full-process",
68-supervisorMode: "launchd",
69-createdAt: 1_000,
70-expiresAt: 61_000,
71-});
60+expect(handoff.kind).toBe(GATEWAY_SUPERVISOR_RESTART_HANDOFF_KIND);
61+expect(handoff.version).toBe(1);
62+expect(handoff.pid).toBe(12_345);
63+expect(handoff.processInstanceId).toBe("gateway-instance-1");
64+expect(handoff.reason).toBe("plugin source changed");
65+expect(handoff.source).toBe("plugin-change");
66+expect(handoff.restartKind).toBe("full-process");
67+expect(handoff.supervisorMode).toBe("launchd");
68+expect(handoff.createdAt).toBe(1_000);
69+expect(handoff.expiresAt).toBe(61_000);
7270expect(fs.statSync(handoffPath(env)).mode & 0o777).toBe(0o600);
73-expect(readGatewayRestartHandoffSync(env, 1_500)).toMatchObject({
74-pid: 12_345,
75-reason: "plugin source changed",
76-});
71+const persisted = readGatewayRestartHandoffSync(env, 1_500);
72+expect(persisted?.pid).toBe(12_345);
73+expect(persisted?.reason).toBe("plugin source changed");
7774});
78757976it("consumes a fresh handoff by exited pid instead of current process pid", () => {
@@ -88,18 +85,15 @@ describe("gateway restart handoff", () => {
8885createdAt: 2_000,
8986});
908791-expect(
92-consumeGatewayRestartHandoffForExitedProcessSync({
93- env,
94-exitedPid: process.pid + 1,
95-now: 2_001,
96-}),
97-).toMatchObject({
98-pid: process.pid + 1,
99-source: "gateway-update",
100-restartKind: "update-process",
101-supervisorMode: "systemd",
88+const consumed = consumeGatewayRestartHandoffForExitedProcessSync({
89+ env,
90+exitedPid: process.pid + 1,
91+now: 2_001,
10292});
93+expect(consumed?.pid).toBe(process.pid + 1);
94+expect(consumed?.source).toBe("gateway-update");
95+expect(consumed?.restartKind).toBe("update-process");
96+expect(consumed?.supervisorMode).toBe("systemd");
10397expect(fs.existsSync(handoffPath(env))).toBe(false);
10498});
10599@@ -247,8 +241,8 @@ describe("gateway restart handoff", () => {
247241consumeGatewayRestartHandoffForExitedProcessSync({
248242 env,
249243exitedPid: 12_345,
250-}),
251-).toMatchObject({ pid: 12_345 });
244+})?.pid,
245+).toBe(12_345);
252246});
253247254248it("formats a concise diagnostic line for status surfaces", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。