feat(update): add startup health rollback fuse

This commit is contained in:
chengma
2026-07-13 12:23:46 +08:00
parent 04124060fc
commit f6db4f0d62
16 changed files with 481 additions and 14 deletions
+34
View File
@@ -1646,6 +1646,7 @@ class GuiTests(TempDirMixin, unittest.TestCase):
staged = SimpleNamespace(
version="1.2.0",
staging_dir=os.path.abspath(staging_root),
sha256="a" * 64,
)
def prepare(_metadata, _install_root, **callbacks):
@@ -1738,6 +1739,39 @@ class GuiTests(TempDirMixin, unittest.TestCase):
self.assertEqual("重试", dialog.action_button.text())
self.assertIsNone(dialog.thread)
def test_startup_update_gate_fuses_a_previously_failed_release(self):
captured = []
class FakeDialog:
def __init__(self, result, parent=None):
captured.append(result)
def exec(self):
return 0
result = update_check.UpdateCheckResult(
current_version="1.0.0",
checked=True,
forced=True,
latest_version="1.2.0",
download_url="https://cm.833729.com/cmshopee.zip",
sha256="a" * 64,
size_bytes=100,
package_format="cmshopee-portable-v1",
updater_protocol=1,
)
with mock.patch(
"app.gui.update_health.get_failed_release",
return_value={"reason": "新版未就绪"},
):
allowed = gui._run_startup_update_gate(
checker=lambda: result,
dialog_factory=FakeDialog,
)
self.assertFalse(allowed)
self.assertIn("已停止重复安装", captured[0].automatic_update_error)
def test_startup_update_gate_check_failure_allows_entry_and_logs(self):
result = update_check.UpdateCheckResult(
current_version="1.0.0",