mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 08:01:12 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
/** Tests plugin loader cache state keys, invalidation, and reset behavior. */
|
|
import { describe, expect, it } from "vitest";
|
|
import { PluginLoaderCacheState } from "./loader-cache-state.js";
|
|
|
|
describe("PluginLoaderCacheState", () => {
|
|
it("evicts the least recently used registry cache entry", () => {
|
|
const cache = new PluginLoaderCacheState<string>(2);
|
|
|
|
cache.set("", "empty");
|
|
cache.set("a", "alpha");
|
|
cache.set("b", "bravo");
|
|
expect(cache.get("a")).toBe("alpha");
|
|
|
|
cache.set("c", "charlie");
|
|
|
|
expect(cache.get("b")).toBeUndefined();
|
|
expect(cache.get("a")).toBe("alpha");
|
|
expect(cache.get("c")).toBe("charlie");
|
|
});
|
|
|
|
it("clears registry, in-flight, and warning state together", () => {
|
|
const cache = new PluginLoaderCacheState<string>(2);
|
|
|
|
cache.set("demo", "registry");
|
|
cache.beginLoad("demo");
|
|
cache.recordOpenAllowlistWarning("demo-warning");
|
|
|
|
cache.clear();
|
|
|
|
expect(cache.get("demo")).toBeUndefined();
|
|
expect(cache.isLoadInFlight("demo")).toBe(false);
|
|
expect(cache.hasOpenAllowlistWarning("demo-warning")).toBe(false);
|
|
});
|
|
|
|
it("clears cached registries without dropping in-flight load guards", () => {
|
|
const cache = new PluginLoaderCacheState<string>(2);
|
|
|
|
cache.set("demo", "registry");
|
|
cache.beginLoad("demo");
|
|
cache.recordOpenAllowlistWarning("demo-warning");
|
|
|
|
cache.clearCachedRegistries();
|
|
|
|
expect(cache.get("demo")).toBeUndefined();
|
|
expect(cache.isLoadInFlight("demo")).toBe(true);
|
|
expect(cache.hasOpenAllowlistWarning("demo-warning")).toBe(false);
|
|
});
|
|
});
|