refactor(server): cron validation (#13990)

This commit is contained in:
Jason Rasmussen 2024-11-07 12:27:52 -05:00 committed by GitHub
parent dc2de47204
commit e84ad084d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 40 additions and 78 deletions

View file

@ -88,26 +88,6 @@ describe(BackupService.name, () => {
});
});
describe('onConfigValidateEvent', () => {
it('should allow a valid cron expression', () => {
expect(() =>
sut.onConfigValidate({
newConfig: { backup: { database: { cronExpression: '0 0 * * *' } } } as SystemConfig,
oldConfig: {} as SystemConfig,
}),
).not.toThrow(expect.stringContaining('Invalid cron expression'));
});
it('should fail for an invalid cron expression', () => {
expect(() =>
sut.onConfigValidate({
newConfig: { backup: { database: { cronExpression: 'foo' } } } as SystemConfig,
oldConfig: {} as SystemConfig,
}),
).toThrow(/Invalid cron expression.*/);
});
});
describe('cleanupDatabaseBackups', () => {
it('should do nothing if not reached keepLastAmount', async () => {
systemMock.get.mockResolvedValue(systemConfigStub.backupEnabled);