File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ def start_run(
113113 set_ = {
114114 "total_count" : total_count ,
115115 "params" : params ,
116+ "status" : STATUS_IN_PROGRESS ,
117+ "completed_at" : None ,
116118 },
117119 )
118120 .returning (TaskRun .id )
Original file line number Diff line number Diff line change @@ -64,6 +64,22 @@ def test_start_run_caches_task_run_id(self):
6464
6565 self .assertEqual (tracker .task_run_id , run_uuid )
6666
67+ def test_start_run_resets_status_to_in_progress_on_rerun (self ):
68+ """Re-running the same task_name/run_id must reset status and completed_at on conflict."""
69+ tracker , session = _make_tracker ()
70+ run_uuid = uuid .uuid4 ()
71+ execute_result = MagicMock ()
72+ execute_result .scalar_one .return_value = run_uuid
73+ session .execute .return_value = execute_result
74+
75+ tracker .start_run (total_count = 5 )
76+
77+ stmt_compiled = str (session .execute .call_args [0 ][0 ])
78+ # The ON CONFLICT DO UPDATE clause must include status and completed_at
79+ self .assertIn ("DO UPDATE SET" , stmt_compiled )
80+ self .assertIn ("status" , stmt_compiled )
81+ self .assertIn ("completed_at" , stmt_compiled )
82+
6783
6884class TestTaskExecutionTrackerIsTriggered (unittest .TestCase ):
6985 def test_returns_true_when_triggered_row_exists (self ):
You can’t perform that action at this time.
0 commit comments