import { describe, it, expect } from 'vitest'; import { ingest } from '../../lib/api/routes/backups.js'; describe('backups ingest schema', () => { it('accepts a valid run', () => { const r = ingest.safeParse({ ok: true, total_bytes: 2400000000, won_free_bytes: 33000000000, guests: [{ vmid: 310, name: 'void-db', bytes: 518000000 }], duration_sec: 950 }); expect(r.success).toBe(true); }); it('accepts an empty body (all fields optional)', () => { expect(ingest.safeParse({}).success).toBe(true); }); it('rejects negative bytes', () => { expect(ingest.safeParse({ total_bytes: -5 }).success).toBe(false); }); it('rejects malformed guests', () => { expect(ingest.safeParse({ guests: [{ vmid: 1 }] }).success).toBe(false); }); });