okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Engine-less app update: tauri.update.conf.json drops engine-bundle so one latest.json entry per OS fits every installer variant; tests for the overlay, for the engine-less update on an installed AMD engine, and for the release engine selection (CUDA 13/12 by driver and card, HIP by gfx, Metal)604e23cd9

main
3.4 KiB63 linesraw
1"""The release app configuration: the engine travels inside every installer, the updater signs, the Mac minimum matches the Metal engine."""
2from __future__ import annotations
3
4import json
5import unittest
6from pathlib import Path
7
8TAURI = Path(__file__).resolve().parents[2] / "apps" / "desktop" / "src-tauri"
9
10
11def load(name: str) -> dict:
12    return json.loads((TAURI / name).read_text(encoding="utf-8-sig"))
13
14
15def merge_patch(base, patch):
16    """RFC 7396, the way `tauri build --config <file>` layers an overlay: a null removes the key."""
17    if not isinstance(patch, dict):
18        return patch
19    out = dict(base) if isinstance(base, dict) else {}
20    for key, value in patch.items():
21        if value is None:
22            out.pop(key, None)
23        else:
24            out[key] = merge_patch(out.get(key), value)
25    return out
26
27
28class ReleaseConfig(unittest.TestCase):
29    def test_every_installer_bundles_the_engine(self):
30        self.assertEqual(load("tauri.conf.json")["bundle"]["resources"]["resources/engine-bundle"], "engine-bundle")
31        self.assertEqual(load("tauri.tester.conf.json")["bundle"]["resources"]["resources/engine-bundle"], "engine-bundle")   # the same place
32
33    def test_the_release_overlay_makes_signed_updater_artifacts(self):
34        self.assertIs(load("tauri.release.conf.json")["bundle"]["createUpdaterArtifacts"], True)
35        self.assertIs(load("tauri.conf.json")["bundle"]["createUpdaterArtifacts"], False)       # a development build needs no private key
36
37    def test_the_mac_app_needs_the_macos_the_metal_engine_needs(self):
38        self.assertEqual(load("tauri.conf.json")["bundle"]["macOS"]["minimumSystemVersion"], "15.0")
39
40    def test_the_updater_points_at_github_releases(self):
41        up = load("tauri.conf.json")["plugins"]["updater"]
42        self.assertEqual(up["endpoints"], ["https://github.com/Niko1221/Strata/releases/latest/download/latest.json"])
43        self.assertNotIn("REPLACE", up["pubkey"])
44
45    def test_the_update_overlay_drops_only_the_engine(self):
46        """The app update (latest.json) is built with tauri.update.conf.json: the same app without engine-bundle, so one update
47        fits every installer variant (CUDA 13, CUDA 12, AMD) and downloads 0 engine bytes. Engines come per card from the feed."""
48        full = load("tauri.conf.json")
49        update = merge_patch(full, load("tauri.update.conf.json"))
50        self.assertNotIn("resources/engine-bundle", update["bundle"]["resources"])
51        self.assertEqual({k: v for k, v in full["bundle"]["resources"].items() if k != "resources/engine-bundle"}, update["bundle"]["resources"])
52        self.assertEqual({k: v for k, v in full["bundle"].items() if k != "resources"}, {k: v for k, v in update["bundle"].items() if k != "resources"})
53        self.assertEqual(full["plugins"], update["plugins"])        # same key, same endpoint: it is the same app
54        self.assertNotIn("endpoints", load("tauri.update.conf.json").get("plugins", {}))
55
56    def test_one_endpoint_and_no_variant_specific_updater_config(self):
57        """Three platform keys in one latest.json is the whole design; a variant-specific endpoint would give an AMD or CUDA 12 PC another variant's installer."""
58        for name in ("tauri.conf.json", "tauri.release.conf.json", "tauri.tester.conf.json", "tauri.update.conf.json"):
59            self.assertNotIn("{{", json.dumps(load(name).get("plugins", {})), name)
60
61
62if __name__ == "__main__":
63    unittest.main()