feat: 完善数据库备份管理与版本读取 (#6450)

This commit is contained in:
InfinityPacer
2026-08-25 16:05:45 +08:00
committed by GitHub
parent b952a3e407
commit d58c8d2b17
38 changed files with 1846 additions and 459 deletions
+42
View File
@@ -0,0 +1,42 @@
from pathlib import Path
from app.chain.system import SystemChain
from app.runtime import version as runtime_version
def test_installed_frontend_version_prefers_deployed_resource(
tmp_path: Path,
monkeypatch,
) -> None:
frontend_path = tmp_path / "public"
frontend_path.mkdir()
(frontend_path / "version.txt").write_text("v3.2.1\n", encoding="utf-8")
monkeypatch.setattr(runtime_version, "is_frozen", lambda: False)
monkeypatch.setattr(runtime_version, "is_windows", lambda: False)
monkeypatch.setattr(
runtime_version,
"get_runtime_setting",
lambda key: frontend_path if key == "FRONTEND_PATH" else tmp_path / "config",
)
assert runtime_version.get_frontend_version() == "v3.2.1"
assert SystemChain.get_frontend_version() == "v3.2.1"
def test_installed_frontend_version_falls_back_to_release_declaration(
tmp_path: Path,
monkeypatch,
) -> None:
monkeypatch.setattr(runtime_version, "is_frozen", lambda: False)
monkeypatch.setattr(runtime_version, "is_windows", lambda: False)
monkeypatch.setattr(runtime_version, "_FRONTEND_VERSION", "v3.0.0")
monkeypatch.setattr(
runtime_version,
"get_runtime_setting",
lambda key: tmp_path / key.lower(),
)
assert runtime_version.get_frontend_version() == "v3.0.0"
assert (
runtime_version.get_frontend_version(fallback_to_declared=False) is None
)