Harden live release workflow #25

This commit is contained in:
2026-07-31 09:28:45 +02:00
parent 939dc9819d
commit e8b0645ea6
19 changed files with 223 additions and 43 deletions
+7 -15
View File
@@ -453,27 +453,19 @@ def test_worker_failure_stops_retrying_after_limit(tmp_path, monkeypatch):
assert updated["attempt_count"] == main.MAX_RETRY_ATTEMPTS
def test_control_update_runs_configured_command(tmp_path, monkeypatch):
def test_control_update_schedules_configured_command_with_release_tag(tmp_path, monkeypatch):
main, _download, _movies, _tv = configure_main(tmp_path, monkeypatch)
main.settings.update_command = ["upgrade", "now"]
monkeypatch.setattr(main, "check_update_available", lambda: {"status": "update_available", "current_version": "0.1.0", "latest_version": "0.2.0", "update_available": True, "release_url": None})
calls = []
monkeypatch.setattr(main, "_schedule_update", calls.append)
def fake_run(command, **kwargs):
calls.append((command, kwargs))
return main.subprocess.CompletedProcess(command, 0, stdout="updated", stderr="")
result = main.update_service(expected_tag="0.2.0")
monkeypatch.setattr(main.subprocess, "run", fake_run)
result = main.update_service()
assert result["status"] == "update_available"
assert result["command_result"]["status"] == "ok"
assert result["command_result"]["command"] == ["upgrade", "now"]
assert result["command_result"]["stdout"] == "updated"
assert calls[0][0] == ["upgrade", "now"]
assert calls[0][1].get("shell") is not True
assert result["status"] == "update_scheduled"
assert result["command"] == ["upgrade", "now", "0.2.0"]
assert calls == [["upgrade", "now", "0.2.0"]]
def test_control_update_skips_command_when_current(tmp_path, monkeypatch):
@@ -486,7 +478,7 @@ def test_control_update_skips_command_when_current(tmp_path, monkeypatch):
monkeypatch.setattr(main.subprocess, "run", fake_run)
result = main.update_service()
result = main.update_service(expected_tag="v0.2.0")
assert result["status"] == "current"
assert result["command"] == ["upgrade", "now"]