feat: purge import history by retention
This commit is contained in:
24
server/importLogRetention.test.ts
Normal file
24
server/importLogRetention.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
IMPORT_LOG_RETENTION_OPTIONS,
|
||||
getImportLogRetentionCutoff,
|
||||
isImportLogRetentionMonths,
|
||||
} from "@shared/importLogRetention";
|
||||
|
||||
describe("rétention des journaux d'import", () => {
|
||||
it("propose uniquement les périodes de purge autorisées", () => {
|
||||
expect(IMPORT_LOG_RETENTION_OPTIONS).toEqual([3, 6, 12]);
|
||||
expect(isImportLogRetentionMonths(3)).toBe(true);
|
||||
expect(isImportLogRetentionMonths(6)).toBe(true);
|
||||
expect(isImportLogRetentionMonths(12)).toBe(true);
|
||||
expect(isImportLogRetentionMonths(9)).toBe(false);
|
||||
});
|
||||
|
||||
it("calcule une date limite calendaire sans modifier la date de référence", () => {
|
||||
const now = new Date("2026-10-09T12:00:00.000Z");
|
||||
const cutoff = getImportLogRetentionCutoff(6, now);
|
||||
|
||||
expect(cutoff.toISOString()).toBe("2026-04-09T12:00:00.000Z");
|
||||
expect(now.toISOString()).toBe("2026-10-09T12:00:00.000Z");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user