appstore: document why three fixtures can't hit the purge race
- Commit
954320dc9c35f0c4afa71f34f739127251ec8bfc- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-23 00:17 UTC (13 days ago)
- Parents
945dc33
AppStoreViewModelTest, HomeOpsTest and PhoneSourceToggleTest seed catalogue rows without an init-settle, the shape that wedged two sibling classes. A probe replicating each fixture proves none can bite: purgeDisabled deletes only disabled sources' repoUrls, and the seeds these assertions actually read carry the enabled MODERN_APPS URL (HomeOpsTest's F-Droid row is purged but never read back). Each file now documents why no settle/reseed is needed, so the next fixture author doesn't cargo-cult it. Verified: classes x3 under taskset and the full Native companion 186/186 green.
Diff
appstore/src/test/java/com/vayunmathur/appstore/util/AppStoreViewModelTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/util/AppStoreViewModelTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/util/AppStoreViewModelTest.ktindex bb0702b22a..0cb03ed05f 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/util/AppStoreViewModelTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/util/AppStoreViewModelTest.kt@@ -47,6 +47,16 @@ class AppStoreViewModelTest { .allowMainThreadQueries() .build() runBlocking {+ // No init-settle needed (unlike DetailAndBrowseOpsTest):+ // init's purgeDisabled deletes by repoUrl, and only for+ // repos whose source is disabled โ on a fresh install that+ // is the F-Droid/Izzy URLs. This row is stamped with the+ // MODERN_APPS repo URL (enabled by default), so the purge+ // can never delete it however the looper schedules init+ // against the test below; the "modern apps reach home"+ // condition stays satisfiable. Verified by a probe that+ // drove init to its modern-recent settle first and then+ // read the DAO: the row was still there. db.cachedAppDao().upsert( app("com.example.modern", AppSource.MODERN_APPS, "Modern One") .toEntity().copy(repoUrl = DefaultRepos.MODERN_APPS.url),
appstore/src/test/java/com/vayunmathur/appstore/util/HomeOpsTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/util/HomeOpsTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/util/HomeOpsTest.ktindex 0729e31c25..b19a9596a3 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/util/HomeOpsTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/util/HomeOpsTest.kt@@ -48,6 +48,17 @@ class HomeOpsTest { runBlocking { // MODERN_APPS is enabled by default; the search filters to enabled // sources, and F-Droid starts off.+ //+ // No init-settle/reseed needed, though this row IS one the+ // startup purge can delete: toEntity() defaults a null+ // repoUrl to the F-Droid repo URL, so init's purgeDisabled+ // (which deletes by repoUrl for disabled sources) removes+ // it โ a probe that pumped init first confirmed the table+ // ends up empty. It cannot bite because no test here reads+ // the catalogue back: buildSections/merge are exercised+ // with in-memory arguments and the search test drives the+ // ViewModel's flows directly, so nothing awaits a state+ // this row could have produced. db.cachedAppDao().upsert( app("com.example.alpha", AppSource.MODERN_APPS, "Alpha").toEntity(), )
appstore/src/test/java/com/vayunmathur/appstore/util/PhoneSourceToggleTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/util/PhoneSourceToggleTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/util/PhoneSourceToggleTest.ktindex e690e85a1b..4b7a783f64 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/util/PhoneSourceToggleTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/util/PhoneSourceToggleTest.kt@@ -43,6 +43,20 @@ class PhoneSourceToggleTest { .build() // The library only lists installed apps a source vouches for: // seed the catalogue row that attributes this test app.+ //+ // No init-settle needed (unlike DetailAndBrowseOpsTest), and+ // deliberately no persisted enabled-set pre-seed either:+ // toggling sources is this class's subject, so init must start+ // from the same persisted state production starts from. The+ // seeded row is stamped with the MODERN_APPS repo URL,+ // and init's purgeDisabled only deletes rows carrying a+ // disabled source's repo URL (F-Droid/Izzy on a fresh+ // install), so the purge can never remove the one row+ // `refreshInstalled` depends on, however init is scheduled โ+ // a probe that settled init first confirmed the row (and the+ // library attribution) survives. The toggle tests themselves+ // seed no catalogue rows at all; they drive the ViewModel's+ // flows and the enabled set directly. kotlinx.coroutines.runBlocking { db.cachedAppDao().upsert( UnifiedApp(