This commit is contained in:
1 parent
16019ee649
commit
329b7756f4
17 files changed
+754
-85
No files matched your search
@@ -205,6 +205,71 @@ def test_forced_update_prefers_matching_delta_package(tmp_path):
|
||||
assert result.delta_path == launched[0]
|
||||
|
||||
|
||||
def test_forced_update_picks_matching_delta_from_list(tmp_path):
|
||||
from douyin.updater.force_update import UpdateSettings, perform_forced_update
|
||||
|
||||
import zipfile
|
||||
|
||||
file_payload = b"latest bytes"
|
||||
file_sha = hashlib.sha256(file_payload).hexdigest()
|
||||
delta_zip = tmp_path / "delta-source.zip"
|
||||
with zipfile.ZipFile(delta_zip, "w") as zf:
|
||||
zf.writestr(
|
||||
"manifest.json",
|
||||
json.dumps(
|
||||
{
|
||||
"schema": 1,
|
||||
"from_version": "3.3.7",
|
||||
"to_version": "3.3.9",
|
||||
"files": [{"path": "DouyinGuajiGUI.exe", "sha256": file_sha, "size": len(file_payload)}],
|
||||
"delete": [],
|
||||
},
|
||||
ensure_ascii=False,
|
||||
),
|
||||
)
|
||||
zf.writestr("files/DouyinGuajiGUI.exe", file_payload)
|
||||
delta_payload = delta_zip.read_bytes()
|
||||
delta_sha = hashlib.sha256(delta_payload).hexdigest()
|
||||
settings = UpdateSettings(enabled=True, manifest_url="https://example.test/update.json", download_dir=tmp_path)
|
||||
downloaded: list[str] = []
|
||||
|
||||
def download(url: str, dest: Path, timeout: float) -> None:
|
||||
downloaded.append(url)
|
||||
dest.write_bytes(delta_payload)
|
||||
|
||||
result = perform_forced_update(
|
||||
settings,
|
||||
current_version="3.3.7",
|
||||
fetch_manifest=lambda url, timeout: {
|
||||
"version": "3.3.9",
|
||||
"url": "https://example.test/full.exe",
|
||||
"sha256": "0" * 64,
|
||||
"delta": [
|
||||
{
|
||||
"from_version": "3.3.8",
|
||||
"to_version": "3.3.9",
|
||||
"url": "https://example.test/DouyinGuaji-3.3.8_to_3.3.9_delta.zip",
|
||||
"filename": "DouyinGuaji-3.3.8_to_3.3.9_delta.zip",
|
||||
"sha256": "1" * 64,
|
||||
},
|
||||
{
|
||||
"from_version": "3.3.7",
|
||||
"to_version": "3.3.9",
|
||||
"url": "https://example.test/DouyinGuaji-3.3.7_to_3.3.9_delta.zip",
|
||||
"filename": "DouyinGuaji-3.3.7_to_3.3.9_delta.zip",
|
||||
"sha256": delta_sha,
|
||||
},
|
||||
],
|
||||
},
|
||||
download_file=download,
|
||||
launch_installer=lambda cmd: pytest.fail("should not launch full installer"),
|
||||
launch_delta_update=lambda path, version: None,
|
||||
)
|
||||
|
||||
assert result.status == "delta_update_started"
|
||||
assert downloaded == ["https://example.test/DouyinGuaji-3.3.7_to_3.3.9_delta.zip"]
|
||||
|
||||
|
||||
def test_forced_update_falls_back_to_full_installer_when_delta_download_fails(tmp_path):
|
||||
from douyin.updater.force_update import UpdateSettings, perform_forced_update
|
||||
|
||||
|
||||
Reference in new issue
Block a user