chore(backup): polish — boundary test, roundtrip lock-in, precompute today
Code reviewer minor nitpicks: - Add test for inkling-2026-02-30.sqlite (locks roundtrip-validation contract) - Add test for weekly window inclusive at oldest boundary - Precompute today=startOfDayUtc(now) once outside the loop, pass to helpers No behavior change; tests added cover existing semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,12 @@ describe('parseBackupFilename', () => {
|
||||
expect(parseBackupFilename('inkling-2026-13-99.sqlite')).toBeNull();
|
||||
expect(parseBackupFilename('.last-snapshot')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for date that JS would silently coerce (roundtrip lock-in)', () => {
|
||||
// Without the toISOString roundtrip check, JS coerces 2026-02-30 to 2026-03-02.
|
||||
// This test locks in the roundtrip-validation contract.
|
||||
expect(parseBackupFilename('inkling-2026-02-30.sqlite')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyGfsRetention', () => {
|
||||
@@ -52,6 +58,14 @@ describe('applyGfsRetention', () => {
|
||||
expect(r.remove).toContain('inkling-2026-03-09.sqlite');
|
||||
});
|
||||
|
||||
it('weekly window is inclusive at oldest boundary', () => {
|
||||
// 2026-03-23 is exactly 4*7 days before anchor Monday 2026-04-20.
|
||||
// Locks in the boundary semantic explicitly.
|
||||
const r = applyGfsRetention(names('2026-03-23', '2026-03-16'), NOW);
|
||||
expect(r.keep).toContain('inkling-2026-03-23.sqlite');
|
||||
expect(r.remove).toContain('inkling-2026-03-16.sqlite');
|
||||
});
|
||||
|
||||
it('keeps month-firsts within last 6 months', () => {
|
||||
// Last 6 month-firsts from 2026-04-26: 2026-04-01, 2026-03-01, 2026-02-01,
|
||||
// 2026-01-01, 2025-12-01, 2025-11-01
|
||||
|
||||
Reference in New Issue
Block a user