Files
PaperClipAI/server/src/__tests__/skill-version-retention-config.test.ts
T
86c965ce7a fix(skills): expire unused version caches and restore saved contents (#16433)
Expire idle skill-version caches with durable runtime pins, bounded discovery, conservative retention, and database-backed restoration.

Co-Authored-By: Dotta <cryppadotta@users.noreply.github.com>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-15 12:20:57 -05:00

27 lines
1.2 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { loadConfig } from "../config.ts";
describe("skill version retention config parsing", () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it("uses the defaults when the variables are not set", () => {
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_KEEP", undefined);
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_GRACE_MINUTES", undefined);
expect(loadConfig()).toMatchObject({ skillVersionRetentionKeepNewest: 0, skillVersionRetentionGraceMinutes: 60 });
});
it("accepts explicit non-negative values, including 0", () => {
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_KEEP", " 0 ");
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_GRACE_MINUTES", "30");
expect(loadConfig()).toMatchObject({ skillVersionRetentionKeepNewest: 0, skillVersionRetentionGraceMinutes: 30 });
});
it.each(["", " ", "-1", "many"])("falls back to the defaults for %j", (value) => {
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_KEEP", value);
vi.stubEnv("PAPERCLIP_SKILL_VERSION_RETENTION_GRACE_MINUTES", value);
expect(loadConfig()).toMatchObject({ skillVersionRetentionKeepNewest: 0, skillVersionRetentionGraceMinutes: 60 });
});
});