fix: keep secret target cache unscoped · openclaw/openclaw@156068a
shakkernerd
·
2026-05-07
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | + |
| 3 | +const metadataMocks = vi.hoisted(() => ({ |
| 4 | +getCurrentPluginMetadataSnapshot: vi.fn(() => undefined), |
| 5 | +loadPluginMetadataSnapshot: vi.fn(() => ({ plugins: [] })), |
| 6 | +})); |
| 7 | + |
| 8 | +vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({ |
| 9 | +getCurrentPluginMetadataSnapshot: metadataMocks.getCurrentPluginMetadataSnapshot, |
| 10 | +})); |
| 11 | + |
| 12 | +vi.mock("../plugins/plugin-metadata-snapshot.js", () => ({ |
| 13 | +loadPluginMetadataSnapshot: metadataMocks.loadPluginMetadataSnapshot, |
| 14 | +})); |
| 15 | + |
| 16 | +describe("getSecretTargetRegistry metadata reuse", () => { |
| 17 | +beforeEach(() => { |
| 18 | +vi.resetModules(); |
| 19 | +metadataMocks.getCurrentPluginMetadataSnapshot.mockClear(); |
| 20 | +metadataMocks.getCurrentPluginMetadataSnapshot.mockReturnValue(undefined); |
| 21 | +metadataMocks.loadPluginMetadataSnapshot.mockClear(); |
| 22 | +metadataMocks.loadPluginMetadataSnapshot.mockReturnValue({ plugins: [] }); |
| 23 | +}); |
| 24 | + |
| 25 | +it("does not request workspace-scoped current metadata for the configless global cache", async () => { |
| 26 | +const { getSecretTargetRegistry } = await import("./target-registry-data.js"); |
| 27 | + |
| 28 | +getSecretTargetRegistry(); |
| 29 | + |
| 30 | +expect(metadataMocks.getCurrentPluginMetadataSnapshot).toHaveBeenCalledWith({ |
| 31 | +config: {}, |
| 32 | +env: process.env, |
| 33 | +}); |
| 34 | +expect(metadataMocks.getCurrentPluginMetadataSnapshot).not.toHaveBeenCalledWith( |
| 35 | +expect.objectContaining({ allowWorkspaceScopedSnapshot: true }), |
| 36 | +); |
| 37 | +expect(metadataMocks.loadPluginMetadataSnapshot).toHaveBeenCalledWith({ |
| 38 | +config: {}, |
| 39 | +env: process.env, |
| 40 | +}); |
| 41 | +}); |
| 42 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。