Modern Apps git

← Modern-Apps.git

clock: seed the legacy world-clock set with the suspending add

Commit
4a34302c47470beb6977712bf35bd294303ec767
Author
Vayun Mathur <[email protected]>
When
2026-11-17 12:21 UTC (19 days ago)
Parents
920b906
CI failed WorldClockCitiesTest.migrateSeedsSortedLegacySetOnce. The test seeded the legacy unordered set through DataStoreUtils.addStringToSet, which is fire-and-forget (it launches on the store's scope), and then polled getStringSetAwait with a fixed budget of 50 tries at 20ms. On a loaded CI box the two edits had not landed within that budget and the size assertion failed; the same test passes unloaded.

Use the existing suspending addStringToSetIfAbsent instead: each write is committed to the store before the call returns, so the seeded state the migration contract is asserted against is deterministic and there is nothing to poll. The assertion itself is unchanged (the ordered key already holds an empty write, so migrate stays a no-op and the ordered flow stays empty).

Verified: :clock:testDevUnitTest green twice sequentially, and green in a parallel all-module run.

Diff

clock/src/test/java/com/vayunmathur/clock/platform/WorldClockCitiesTest.kt
diff --git a/clock/src/test/java/com/vayunmathur/clock/platform/WorldClockCitiesTest.kt b/clock/src/test/java/com/vayunmathur/clock/platform/WorldClockCitiesTest.ktindex 94c05fb132..717e306961 100644--- a/clock/src/test/java/com/vayunmathur/clock/platform/WorldClockCitiesTest.kt+++ b/clock/src/test/java/com/vayunmathur/clock/platform/WorldClockCitiesTest.kt@@ -45,16 +45,12 @@ class WorldClockCitiesTest {         WorldClockCities.set(ds, emptyList())         // Seed the legacy unordered set, then clear the ordered key via an empty write is not         // enough (it stores ""), so remove both keys first through a fresh migrate cycle:-        ds.addStringToSet("time_zones", "Zurich, Switzerland")-        ds.addStringToSet("time_zones", "Athens, Greece")-        // Wait for the async set writes to land.-        var legacy = ds.getStringSetAwait("time_zones")-        var tries = 0-        while (legacy.size < 2 && tries++ < 50) {-            Thread.sleep(20)-            legacy = ds.getStringSetAwait("time_zones")-        }-        assertEquals(2, legacy.size)+        // The suspending add commits each write before returning: the fire-and-forget+        // addStringToSet launches on the store's scope, and polling for its landing+        // with a fixed try count gave up under CI load before the edits ran.+        ds.addStringToSetIfAbsent("time_zones", "Zurich, Switzerland")+        ds.addStringToSetIfAbsent("time_zones", "Athens, Greece")+        assertEquals(2, ds.getStringSetAwait("time_zones").size)         // The ordered key currently holds "" (from the empty set above), which decodes to an         // empty list but is non-null, so migrate is a no-op here; verify that contract.         WorldClockCities.migrate(ds)