fix(reporter): refresh last_heal_timestamp on every heal result
This commit is contained in:
1 parent
469a30df6a
commit
ecda631049
2 files changed
+25
-2
No files matched your search
@@ -147,6 +147,26 @@ class ReporterStateTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(first_ts, second_payload["last_heal_timestamp"])
|
||||
|
||||
@patch("reporter.datetime")
|
||||
def test_update_status_refreshes_last_heal_timestamp_on_each_heal(self, datetime_mock):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
state_file = os.path.join(tmp_dir, "state.json")
|
||||
reporter = LocalStateReporter(state_file=state_file, node_name="n1")
|
||||
|
||||
datetime_mock.now.side_effect = [
|
||||
datetime.fromisoformat("2026-03-06T10:00:00"),
|
||||
datetime.fromisoformat("2026-03-06T10:00:00"),
|
||||
datetime.fromisoformat("2026-03-06T10:05:00"),
|
||||
datetime.fromisoformat("2026-03-06T10:05:00"),
|
||||
]
|
||||
reporter.update_status(False, 1, heal_result="failed")
|
||||
reporter.update_status(False, 1, heal_result="success")
|
||||
|
||||
with open(state_file, "r") as f:
|
||||
payload = json.load(f)
|
||||
|
||||
self.assertEqual("2026-03-06T10:05:00", payload["last_heal_timestamp"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user