test: isolate channel option metadata cache

This commit is contained in:
Peter Steinberger
2026-05-02 16:24:51 +01:00
parent cbe9cf89be
commit 1885f05bae

View File

@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { __testing, resolveCliChannelOptions } from "./channel-options.js";
import { __testing as startupMetadataTesting } from "./startup-metadata.js";
@@ -22,12 +22,17 @@ vi.mock("../channels/ids.js", () => ({
}));
describe("resolveCliChannelOptions", () => {
afterEach(() => {
beforeEach(() => {
__testing.resetPrecomputedChannelOptionsForTests();
startupMetadataTesting.clearStartupMetadataCache();
vi.clearAllMocks();
});
afterEach(() => {
__testing.resetPrecomputedChannelOptionsForTests();
delete process.env.OPENCLAW_PLUGIN_CATALOG_PATHS;
});
it("uses precomputed startup metadata when available", async () => {
readFileSyncMock.mockReturnValue(
JSON.stringify({ channelOptions: ["cached", "quietchat", "cached"] }),
@@ -49,6 +54,5 @@ describe("resolveCliChannelOptions", () => {
readFileSyncMock.mockReturnValue(JSON.stringify({ channelOptions: ["cached", "quietchat"] }));
expect(resolveCliChannelOptions()).toEqual(["cached", "quietchat"]);
delete process.env.OPENCLAW_PLUGIN_CATALOG_PATHS;
});
});