import { OperationLogRetentionService } from './operation-log-retention.service'; describe('OperationLogRetentionService', () => { const originalEnv = { ...process.env }; afterEach(() => { process.env = { ...originalEnv }; }); it('archives expired logs in bounded batches using the configured retention window', async () => { process.env.OPERATION_LOG_RETENTION_DAYS = '90'; process.env.OPERATION_LOG_ARCHIVE_BATCH_SIZE = '2'; process.env.OPERATION_LOG_ARCHIVE_MAX_BATCHES = '3'; const prisma = { $executeRaw: jest.fn() .mockResolvedValueOnce(2) .mockResolvedValueOnce(1), }; const service = new OperationLogRetentionService(prisma as never); await expect(service.archiveExpiredLogs(new Date('2026-07-14T00:00:00.000Z'))).resolves.toEqual({ archived: 3, cutoff: new Date('2026-04-15T00:00:00.000Z'), retentionDays: 90, }); expect(prisma.$executeRaw).toHaveBeenCalledTimes(2); }); });