test: guard agent runner null helpers · openclaw/openclaw@f56fae7
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
30 | 30 | vi.mock("./models-config.providers.js", () => ({ |
31 | 31 | applyNativeStreamingUsageCompat: (providers: unknown) => providers, |
32 | 32 | enforceSourceManagedProviderSecrets: ({ providers }: { providers: unknown }) => providers, |
| 33 | +normalizeProviderCatalogModelsForConfig: (providers: unknown) => providers, |
33 | 34 | normalizeProviders: ({ providers }: { providers: unknown }) => providers, |
34 | 35 | resolveImplicitProviders: async ({ |
35 | 36 | explicitProviders, |
@@ -272,8 +273,6 @@ function expectCopilotProviderFromPlan(
|
272 | 273 | ? (JSON.parse(plan.contents) as { providers?: Record<string, unknown> }) |
273 | 274 | : {}; |
274 | 275 | const provider = parsed.providers?.["github-copilot"]; |
275 | | -expect(provider).not.toBeNull(); |
276 | | -expect(typeof provider).toBe("object"); |
277 | 276 | if (provider === null || typeof provider !== "object") { |
278 | 277 | throw new Error("Expected GitHub Copilot provider config"); |
279 | 278 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -93,8 +93,9 @@ function callArg(mock: { mock: { calls: unknown[][] } }, callIndex: number, argI
|
93 | 93 | |
94 | 94 | function fetchInit(fetchMock: { mock: { calls: unknown[][] } }, callIndex = 0): RequestInit { |
95 | 95 | const init = callArg(fetchMock, callIndex, 1); |
96 | | -expect(typeof init).toBe("object"); |
97 | | -expect(init).not.toBeNull(); |
| 96 | +if (!init || typeof init !== "object") { |
| 97 | +throw new Error(`expected fetch init for call ${callIndex}`); |
| 98 | +} |
98 | 99 | return init as RequestInit; |
99 | 100 | } |
100 | 101 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,8 +52,9 @@ type MockCallSource = {
|
52 | 52 | }; |
53 | 53 | |
54 | 54 | function requireRecord(value: unknown, label: string): Record<string, unknown> { |
55 | | -expect(value, label).toBeTypeOf("object"); |
56 | | -expect(value, label).not.toBeNull(); |
| 55 | +if (!value || typeof value !== "object") { |
| 56 | +throw new Error(`expected ${label}`); |
| 57 | +} |
57 | 58 | return value as Record<string, unknown>; |
58 | 59 | } |
59 | 60 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -74,8 +74,9 @@ async function invokeWrappedTestStream(
|
74 | 74 | } |
75 | 75 | |
76 | 76 | function requireRecord(value: unknown, label: string): Record<string, unknown> { |
77 | | -expect(value, label).toBeTypeOf("object"); |
78 | | -expect(value, label).not.toBeNull(); |
| 77 | +if (!value || typeof value !== "object") { |
| 78 | +throw new Error(`expected ${label}`); |
| 79 | +} |
79 | 80 | return value as Record<string, unknown>; |
80 | 81 | } |
81 | 82 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -209,8 +209,6 @@ describe("before_tool_call loop detection behavior", () => {
|
209 | 209 | } |
210 | 210 | |
211 | 211 | function requireRecord(value: unknown, label: string): Record<string, unknown> { |
212 | | -expect(typeof value).toBe("object"); |
213 | | -expect(value).not.toBeNull(); |
214 | 212 | if (typeof value !== "object" || value === null) { |
215 | 213 | throw new Error(`${label} was not an object`); |
216 | 214 | } |
@@ -649,8 +647,6 @@ describe("before_tool_call requireApproval handling", () => {
|
649 | 647 | const mockCallGateway = vi.mocked(callGatewayTool); |
650 | 648 | |
651 | 649 | function requireRecord(value: unknown, label: string): Record<string, unknown> { |
652 | | -expect(typeof value).toBe("object"); |
653 | | -expect(value).not.toBeNull(); |
654 | 650 | if (typeof value !== "object" || value === null) { |
655 | 651 | throw new Error(`${label} was not an object`); |
656 | 652 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -75,9 +75,11 @@ describe("compactSkillPaths", () => {
|
75 | 75 | }); |
76 | 76 | |
77 | 77 | const locationMatch = prompt.match(/<location>([^<]+)<\/location>/); |
78 | | -expect(locationMatch).not.toBeNull(); |
79 | | -expect(locationMatch![1]).toContain("~/"); |
80 | | -expect(locationMatch![1]).toContain("\\literal-skill"); |
| 78 | +if (!locationMatch) { |
| 79 | +throw new Error("expected prompt location tag"); |
| 80 | +} |
| 81 | +expect(locationMatch[1]).toContain("~/"); |
| 82 | +expect(locationMatch[1]).toContain("\\literal-skill"); |
81 | 83 | }); |
82 | 84 | |
83 | 85 | it("preserves paths outside home directory", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。