fix: normalize repeat<=0 to None to prevent cron jobs deleting after first run (#2612)
fix: normalize repeat<=0 to None — cron jobs deleted after first run when LLM passes -1
This commit is contained in:
parent
f60ebc7bf2
commit
ca2958ff98
3 changed files with 26 additions and 2 deletions
|
|
@ -313,6 +313,24 @@ class TestMarkJobRun:
|
|||
# Job should be removed after hitting repeat limit
|
||||
assert get_job(job["id"]) is None
|
||||
|
||||
def test_repeat_negative_one_is_infinite(self, tmp_cron_dir):
|
||||
# LLMs often pass repeat=-1 to mean "infinite/forever".
|
||||
# The job must NOT be deleted after runs when repeat <= 0.
|
||||
job = create_job(prompt="Forever", schedule="every 1h", repeat=-1)
|
||||
# -1 should be normalised to None (infinite) at create time
|
||||
assert job["repeat"]["times"] is None
|
||||
# Running it multiple times should never delete it
|
||||
for _ in range(3):
|
||||
mark_job_run(job["id"], success=True)
|
||||
assert get_job(job["id"]) is not None, "job was deleted after run despite infinite repeat"
|
||||
|
||||
def test_repeat_zero_is_infinite(self, tmp_cron_dir):
|
||||
# repeat=0 should also be treated as None (infinite), not "run zero times".
|
||||
job = create_job(prompt="ZeroRepeat", schedule="every 1h", repeat=0)
|
||||
assert job["repeat"]["times"] is None
|
||||
mark_job_run(job["id"], success=True)
|
||||
assert get_job(job["id"]) is not None
|
||||
|
||||
def test_error_status(self, tmp_cron_dir):
|
||||
job = create_job(prompt="Fail", schedule="every 1h")
|
||||
mark_job_run(job["id"], success=False, error="timeout")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue