




















@@ -95,14 +95,11 @@ describe("gateway control-plane write rate limit", () => {
9595const blocked = await runRequest({ method: "config.patch", context, client, handler });
96969797expect(handlerCalls).toHaveBeenCalledTimes(3);
98-expect(blocked).toHaveBeenCalledWith(
99-false,
100-undefined,
101-expect.objectContaining({
102-code: "UNAVAILABLE",
103-retryable: true,
104-}),
105-);
98+const error = blocked.mock.calls[0]?.[2] as { code?: string; retryable?: boolean } | undefined;
99+expect(blocked.mock.calls[0]?.[0]).toBe(false);
100+expect(blocked.mock.calls[0]?.[1]).toBeUndefined();
101+expect(error?.code).toBe("UNAVAILABLE");
102+expect(error?.retryable).toBe(true);
106103expect(logWarn).toHaveBeenCalledTimes(1);
107104});
108105@@ -120,11 +117,9 @@ describe("gateway control-plane write rate limit", () => {
120117await runRequest({ method: "update.run", context, client, handler });
121118122119const blocked = await runRequest({ method: "update.run", context, client, handler });
123-expect(blocked).toHaveBeenCalledWith(
124-false,
125-undefined,
126-expect.objectContaining({ code: "UNAVAILABLE" }),
127-);
120+expect(blocked.mock.calls[0]?.[0]).toBe(false);
121+expect(blocked.mock.calls[0]?.[1]).toBeUndefined();
122+expect(blocked.mock.calls[0]?.[2]?.code).toBe("UNAVAILABLE");
128123129124vi.advanceTimersByTime(60_001);
130125@@ -150,17 +145,13 @@ describe("gateway control-plane write rate limit", () => {
150145const blocked = await runRequest({ method, context, client, handler });
151146152147expect(handlerCalls).not.toHaveBeenCalled();
153-expect(blocked).toHaveBeenCalledWith(
154-false,
155-undefined,
156-expect.objectContaining({
157-code: "UNAVAILABLE",
158-retryable: true,
159-retryAfterMs: 500,
160-details: { reason: "startup-sidecars", method },
161-}),
162-);
163148const error = blocked.mock.calls[0]?.[2];
149+expect(blocked.mock.calls[0]?.[0]).toBe(false);
150+expect(blocked.mock.calls[0]?.[1]).toBeUndefined();
151+expect(error?.code).toBe("UNAVAILABLE");
152+expect(error?.retryable).toBe(true);
153+expect(error?.retryAfterMs).toBe(500);
154+expect(error?.details).toEqual({ reason: "startup-sidecars", method });
164155expect(isRetryableGatewayStartupUnavailableError(error)).toBe(true);
165156},
166157);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。