test: guard memory auth mock calls · openclaw/openclaw@8b6c2bf
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
packages/memory-host-sdk/src/host
| Original file line number | Diff line number | Diff line change |
|---|
@@ -78,7 +78,7 @@ describe("postJsonWithRetry", () => {
|
78 | 78 | expect(postJsonParams.errorPrefix).toBe("memory batch failed"); |
79 | 79 | expect(postJsonParams.attachStatus).toBe(true); |
80 | 80 | |
81 | | -const retryOptions = requireRetryOptions(retryAsyncMock.mock.calls[0]); |
| 81 | +const retryOptions = requireRetryOptions(retryAsyncMock.mock.calls.at(0)); |
82 | 82 | expect(retryOptions.attempts).toBe(3); |
83 | 83 | expect(retryOptions.minDelayMs).toBe(300); |
84 | 84 | expect(retryOptions.maxDelayMs).toBe(2000); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,16 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
26 | 26 | let clearRuntimeAuthProfileStoreSnapshots: typeof import("./auth-profiles.js").clearRuntimeAuthProfileStoreSnapshots; |
27 | 27 | let loadAuthProfileStoreForRuntime: typeof import("./auth-profiles.js").loadAuthProfileStoreForRuntime; |
28 | 28 | |
| 29 | +type MockWithCalls = { mock: { calls: unknown[][] } }; |
| 30 | + |
| 31 | +function firstMockArg(mock: MockWithCalls, label: string) { |
| 32 | +const call = mock.mock.calls.at(0); |
| 33 | +if (!call) { |
| 34 | +throw new Error(`expected ${label} call`); |
| 35 | +} |
| 36 | +return call[0]; |
| 37 | +} |
| 38 | + |
29 | 39 | describe("auth profiles read-only external auth overlay", () => { |
30 | 40 | beforeEach(async () => { |
31 | 41 | vi.resetModules(); |
@@ -59,7 +69,10 @@ describe("auth profiles read-only external auth overlay", () => {
|
59 | 69 | const loaded = loadAuthProfileStoreForRuntime(agentDir, { readOnly: true }); |
60 | 70 | |
61 | 71 | expect(resolveExternalAuthProfilesWithPluginsMock).toHaveBeenCalledTimes(1); |
62 | | -const externalAuthCall = resolveExternalAuthProfilesWithPluginsMock.mock.calls[0]?.[0] as |
| 72 | +const externalAuthCall = firstMockArg( |
| 73 | +resolveExternalAuthProfilesWithPluginsMock, |
| 74 | +"resolveExternalAuthProfilesWithPlugins", |
| 75 | +) as |
63 | 76 | | { |
64 | 77 | config?: unknown; |
65 | 78 | context?: { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。