Files
openclaw/src/cli/command-secret-targets.import.test.ts
2026-04-04 04:58:09 +01:00

25 lines
832 B
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
describe("command secret targets module import", () => {
beforeEach(() => {
vi.resetModules();
});
it("does not touch the registry during module import", async () => {
const listSecretTargetRegistryEntries = vi.fn(() => {
throw new Error("registry touched too early");
});
vi.doMock("../secrets/target-registry.js", () => ({
discoverConfigSecretTargetsByIds: vi.fn(() => []),
listSecretTargetRegistryEntries,
}));
const mod = await import("./command-secret-targets.js");
expect(listSecretTargetRegistryEntries).not.toHaveBeenCalled();
expect(() => mod.getChannelsCommandSecretTargetIds()).toThrow("registry touched too early");
expect(listSecretTargetRegistryEntries).toHaveBeenCalledTimes(1);
});
});