test: clarify guard fallback assertions · openclaw/openclaw@42c9bd5
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -50,22 +50,22 @@ describe("resolveProviderPluginLookupKey", () => {
|
50 | 50 | ).toBe("google"); |
51 | 51 | }); |
52 | 52 | |
53 | | -it("does not throw when runtime provider models is an object map", () => { |
54 | | -expect(() => |
| 53 | +it("falls through when runtime provider models is an object map", () => { |
| 54 | +expect( |
55 | 55 | resolveProviderPluginLookupKey("openrouter", { |
56 | 56 | baseUrl: "https://openrouter.ai/api/v1", |
57 | 57 | models: { "some/model": { api: "openai-completions" } } as never, |
58 | 58 | }), |
59 | | -).not.toThrow(); |
| 59 | +).toBe("openrouter"); |
60 | 60 | }); |
61 | 61 | |
62 | | -it("does not throw when runtime provider models is undefined", () => { |
63 | | -expect(() => |
| 62 | +it("falls through when runtime provider models is undefined", () => { |
| 63 | +expect( |
64 | 64 | resolveProviderPluginLookupKey("openrouter", { |
65 | 65 | baseUrl: "https://openrouter.ai/api/v1", |
66 | 66 | models: undefined as never, |
67 | 67 | }), |
68 | | -).not.toThrow(); |
| 68 | +).toBe("openrouter"); |
69 | 69 | }); |
70 | 70 | |
71 | 71 | it("falls through to the provider key when runtime provider models is non-array", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -21,13 +21,13 @@ function expectAllowed(
|
21 | 21 | currentConfig: Record<string, unknown>, |
22 | 22 | patch: Record<string, unknown>, |
23 | 23 | ): void { |
24 | | -expect(() => |
| 24 | +expect( |
25 | 25 | assertGatewayConfigMutationAllowedForTest({ |
26 | 26 | action: "config.patch", |
27 | 27 | currentConfig, |
28 | 28 | raw: JSON.stringify(patch), |
29 | 29 | }), |
30 | | -).not.toThrow(); |
| 30 | +).toBeUndefined(); |
31 | 31 | } |
32 | 32 | |
33 | 33 | function expectBlockedApply( |
@@ -47,13 +47,13 @@ function expectAllowedApply(
|
47 | 47 | currentConfig: Record<string, unknown>, |
48 | 48 | nextConfig: Record<string, unknown>, |
49 | 49 | ): void { |
50 | | -expect(() => |
| 50 | +expect( |
51 | 51 | assertGatewayConfigMutationAllowedForTest({ |
52 | 52 | action: "config.apply", |
53 | 53 | currentConfig, |
54 | 54 | raw: JSON.stringify(nextConfig), |
55 | 55 | }), |
56 | | -).not.toThrow(); |
| 56 | +).toBeUndefined(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | describe("gateway config mutation guard coverage", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -35,9 +35,6 @@ describe("cron stagger helpers", () => {
|
35 | 35 | }); |
36 | 36 | |
37 | 37 | it("handles missing runtime expr values without throwing", () => { |
38 | | -expect(() => |
39 | | -resolveCronStaggerMs({ kind: "cron" } as unknown as { kind: "cron"; expr: string }), |
40 | | -).not.toThrow(); |
41 | 38 | expect( |
42 | 39 | resolveCronStaggerMs({ kind: "cron" } as unknown as { kind: "cron"; expr: string }), |
43 | 40 | ).toBe(0); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。