test: dedupe server close mock reads · openclaw/openclaw@55aadd2
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,6 +71,10 @@ type DrainActiveSessionsForShutdown = NonNullable<
|
71 | 71 | GatewayCloseHandlerParams["drainActiveSessionsForShutdown"] |
72 | 72 | >; |
73 | 73 | |
| 74 | +function firstMockCall<T extends readonly unknown[]>(mock: { mock: { calls: readonly T[] } }) { |
| 75 | +return mock.mock.calls[0]; |
| 76 | +} |
| 77 | + |
74 | 78 | function createGatewayCloseTestDeps( |
75 | 79 | overrides: Partial<GatewayCloseHandlerParams> = {}, |
76 | 80 | ): GatewayCloseHandlerParams { |
@@ -201,7 +205,7 @@ describe("createGatewayCloseHandler", () => {
|
201 | 205 | await close({ reason: "SIGTERM" }); |
202 | 206 | |
203 | 207 | expect(drainActiveSessionsForShutdown).toHaveBeenCalledTimes(1); |
204 | | -expect(drainActiveSessionsForShutdown.mock.calls.at(0)?.[0]?.reason).toBe("shutdown"); |
| 208 | +expect(firstMockCall(drainActiveSessionsForShutdown)?.[0]?.reason).toBe("shutdown"); |
205 | 209 | }); |
206 | 210 | |
207 | 211 | it("drains the active-session tracker with reason=restart when restartExpectedMs is set", async () => { |
@@ -216,7 +220,7 @@ describe("createGatewayCloseHandler", () => {
|
216 | 220 | await close({ reason: "gateway restarting", restartExpectedMs: 1234 }); |
217 | 221 | |
218 | 222 | expect(drainActiveSessionsForShutdown).toHaveBeenCalledTimes(1); |
219 | | -expect(drainActiveSessionsForShutdown.mock.calls.at(0)?.[0]?.reason).toBe("restart"); |
| 223 | +expect(firstMockCall(drainActiveSessionsForShutdown)?.[0]?.reason).toBe("restart"); |
220 | 224 | }); |
221 | 225 | |
222 | 226 | it("records a warning and continues shutdown when the session-end drain reports a timeout", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。