const test = require("node:test");
const assert = require("node:assert/strict");
const { retentionPolicy, cutoffDate } = require("../src/security/dataLifecycle");

test("retention policy uses safe defaults and positive overrides", () => {
  assert.deepEqual(retentionPolicy({}), {
    raw_audio_days: 30,
    transcript_days: 365,
    session_memory_days: 730,
    backup_expiry_days: 30,
  });
  assert.equal(retentionPolicy({ COACHING_AUDIO_RETENTION_DAYS: "7" }).raw_audio_days, 7);
  assert.equal(retentionPolicy({ COACHING_AUDIO_RETENTION_DAYS: "0" }).raw_audio_days, 30);
});

test("retention cutoff is deterministic", () => {
  assert.equal(cutoffDate(1, new Date("2026-07-22T00:00:00Z")).toISOString(), "2026-07-21T00:00:00.000Z");
});
