test: tighten qmd embed lock assertion · openclaw/openclaw@696eb6c
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3655,23 +3655,38 @@ describe("QmdMemoryManager", () => {
|
3655 | 3655 | const firstSync = first.manager.sync({ reason: "manual", force: true }); |
3656 | 3656 | await vi.advanceTimersByTimeAsync(0); |
3657 | 3657 | expect(embedChildren).toHaveLength(1); |
3658 | | -expect(withFileLockMock).toHaveBeenCalledWith( |
3659 | | -expect.any(String), |
3660 | | -expect.objectContaining({ |
3661 | | -retries: expect.objectContaining({ |
3662 | | -retries: expect.any(Number), |
3663 | | -maxTimeout: 10_000, |
3664 | | -}), |
3665 | | -stale: expect.any(Number), |
3666 | | -}), |
3667 | | -expect.any(Function), |
3668 | | -); |
3669 | | -const lockOptions = withFileLockMock.mock.calls[0]?.[1] as { |
3670 | | -retries: { retries: number }; |
3671 | | -stale: number; |
3672 | | -}; |
3673 | | -expect(lockOptions.retries.retries).toBeGreaterThanOrEqual(90); |
3674 | | -expect(lockOptions.stale).toBeGreaterThanOrEqual(15 * 60 * 1000); |
| 3658 | +const lockCall = withFileLockMock.mock.calls[0] as |
| 3659 | +| [ |
| 3660 | +string, |
| 3661 | +{ |
| 3662 | +retries: { |
| 3663 | +retries: number; |
| 3664 | +factor: number; |
| 3665 | +minTimeout: number; |
| 3666 | +maxTimeout: number; |
| 3667 | +randomize: boolean; |
| 3668 | +}; |
| 3669 | +stale: number; |
| 3670 | +}, |
| 3671 | +() => Promise<unknown>, |
| 3672 | +] |
| 3673 | +| undefined; |
| 3674 | +if (!lockCall) { |
| 3675 | +throw new Error("Expected qmd embed lock call"); |
| 3676 | +} |
| 3677 | +const [lockPath, lockOptions, lockTask] = lockCall; |
| 3678 | +expect(lockPath.endsWith(path.join("qmd", "embed.lock"))).toBe(true); |
| 3679 | +expect(lockOptions).toEqual({ |
| 3680 | +retries: { |
| 3681 | +retries: 90, |
| 3682 | +factor: 1.2, |
| 3683 | +minTimeout: 250, |
| 3684 | +maxTimeout: 10_000, |
| 3685 | +randomize: true, |
| 3686 | +}, |
| 3687 | +stale: 15 * 60 * 1000, |
| 3688 | +}); |
| 3689 | +expect(typeof lockTask).toBe("function"); |
3675 | 3690 | |
3676 | 3691 | const secondSync = second.manager.sync({ reason: "manual", force: true }); |
3677 | 3692 | await vi.advanceTimersByTimeAsync(0); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。