migration 026 backup_runs; POST ingest (owner) from offsite-backup.sh, GET for the Sacred Valley card showing last run, per-guest sizes, Farm free, schedule. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
782 B
JavaScript
22 lines
782 B
JavaScript
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);
|
|
});
|
|
});
|