Add regression tests for platformAsset selection logic#152
Conversation
…lace install The self-updater's in-place install can only extract a .tar.gz/.zip, mount a .dmg, or hand off a .apk; package formats (.deb/.rpm/.appimage) and setup installers are download-only. #99 fixed asset selection picking the alphabetically -first .deb over the .tar.gz on Linux ("Unsupported archive: daccord-linux-x86_64.deb") but shipped no test, so the regression silently re-emerged on v0.2.4. Add regression tests over UpdateController's asset selection using the real release asset set (both .deb and .tar.gz, .deb listed first): platformAsset() never returns an unextractable package, always picks the host-applicable extension, prefers .tar.gz over .deb, and a package-only release falls back to a download link instead of failing mid-install.
- _installableExts and _downloadExts for Windows now prefer the more-specific 'windows-x86_64.zip' suffix before the generic '.zip' fallback, preventing daccord-web.zip (which sorts alphabetically before daccord-windows-x86_64.zip in GitHub's asset list) from being selected as the in-place Windows installer — the same class of bug as the .deb-over-.tar.gz regression being guarded here. - Add a Windows regression test mirroring the Linux .deb/.tar.gz test. - Strengthen the 'selects the extension the host installer can apply' assertion on Windows to verify the name contains 'windows', not just that the extension is .zip. - Fix import ordering in the test file: dart: imports before package:. https://claude.ai/code/session_01HPonjbbg1y1GMMTQLKebce
Code Review — findings and fixes (commit ef464e1)Reviewed 🔴 HIGH — Windows
|
Summary
Adds comprehensive test coverage for the
UpdateController.platformAsset()selection logic to prevent a recurring bug where unextractable package formats (.deb,.rpm,.appimage, etc.) were incorrectly chosen for in-place installation, causing "Unsupported archive" crashes.Changes
Import
universal_platformto enable platform-specific test assertionsAdd test helper functions:
setLatest()— sets up a mock release with specified assets_asset()— creates test asset objects_fullReleaseAssets— realistic asset list mirroring a real multi-platform release (including both.deband.tar.gzfor Linux, in GitHub's alphabetical order)_hostInstallableExt— getter that returns the only extractable extension the current host platform supports (.apkon Android,.zipon Windows,.dmgon macOS,.tar.gzon Linux,nullon web/iOS)Add regression test group
'platformAsset selection (Unsupported archive regression)'with five tests:.deb,.rpm,.appimage,-setup.exe,.msi,.pkgare never selectedImplementation Details
nullcase_fullReleaseAssetslist intentionally mirrors the real v0.2.4 release structure to catch the exact ordering trap that caused the original bugmakeContainer()andcontrollerOf()helpers for consistency with the test suitehttps://claude.ai/code/session_01YMPGSUtRSXJExgsvLxPoCm