okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
604e23cd9
main
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 : 12return 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.""" 17if not isinstance (patch ,dict ): 18return patch 19out = dict (base )if isinstance (base ,dict )else {} 20for key ,value in patch .items (): 21if value is None : 22out .pop (key ,None ) 23else : 24out [key ]= merge_patch (out .get (key ),value ) 25return out 26 27 28class ReleaseConfig (unittest .TestCase ): 29def test_every_installer_bundles_the_engine (self ): 30self .assertEqual (load ("tauri.conf.json" )["bundle" ]["resources" ]["resources/engine-bundle" ],"engine-bundle" ) 31self .assertEqual (load ("tauri.tester.conf.json" )["bundle" ]["resources" ]["resources/engine-bundle" ],"engine-bundle" )# the same place 32 33def test_the_release_overlay_makes_signed_updater_artifacts (self ): 34self .assertIs (load ("tauri.release.conf.json" )["bundle" ]["createUpdaterArtifacts" ],True ) 35self .assertIs (load ("tauri.conf.json" )["bundle" ]["createUpdaterArtifacts" ],False )# a development build needs no private key 36 37def test_the_mac_app_needs_the_macos_the_metal_engine_needs (self ): 38self .assertEqual (load ("tauri.conf.json" )["bundle" ]["macOS" ]["minimumSystemVersion" ],"15.0" ) 39 40def test_the_updater_points_at_github_releases (self ): 41up = load ("tauri.conf.json" )["plugins" ]["updater" ] 42self .assertEqual (up ["endpoints" ], ["https://github.com/Niko1221/Strata/releases/latest/download/latest.json" ]) 43self .assertNotIn ("REPLACE" ,up ["pubkey" ]) 44 45def 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 47fits every installer variant (CUDA 13, CUDA 12, AMD) and downloads 0 engine bytes. Engines come per card from the feed.""" 48full = load ("tauri.conf.json" ) 49update = merge_patch (full ,load ("tauri.update.conf.json" )) 50self .assertNotIn ("resources/engine-bundle" ,update ["bundle" ]["resources" ]) 51self .assertEqual ({k :v for k ,v in full ["bundle" ]["resources" ].items ()if k != "resources/engine-bundle" },update ["bundle" ]["resources" ]) 52self .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" }) 53self .assertEqual (full ["plugins" ],update ["plugins" ])# same key, same endpoint: it is the same app 54self .assertNotIn ("endpoints" ,load ("tauri.update.conf.json" ).get ("plugins" , {})) 55 56def 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.""" 58for name in ("tauri.conf.json" ,"tauri.release.conf.json" ,"tauri.tester.conf.json" ,"tauri.update.conf.json" ): 59self .assertNotIn ("{{" ,json .dumps (load (name ).get ("plugins" , {})),name ) 60 61 62if __name__ == "__main__" : 63unittest .main ()