Compare commits

..

1 Commits

Author SHA1 Message Date
Frédéric Péters 1e5585883c cron: log and capture exceptions, do not create logged errors (#88783)
gitea/wcs/pipeline/head There was a failure building this commit Details
2024-03-27 14:56:47 +01:00
1 changed files with 25 additions and 0 deletions

View File

@ -526,6 +526,31 @@ def test_cron_command_rewind_jobs(settings, freezer):
assert sorted(jobs) == ['job1', 'job2', 'job3']
def test_cron_command_job_exception(settings):
create_temporary_pub()
def job1(pub, job=None):
raise Exception('Error')
@classmethod
def register_test_cronjobs(cls):
cls.register_cronjob(CronJob(job1, name='job1', days=[10]))
get_publisher().set_tenant_by_hostname('example.net')
sql.mark_cron_status('done')
with mock.patch('wcs.publisher.WcsPublisher.register_cronjobs', register_test_cronjobs):
get_publisher_class().cronjobs = []
call_command('cron', job_name='job1', domain='example.net')
assert get_logs('example.net') == [
'start',
"running jobs: ['job1']",
'exception running job job1: Error',
]
clean_temporary_pub()
def test_clean_afterjobs():
pub = create_temporary_pub()