Repository navigation
test(chat): tear the coordinator down however a test ends - #1512
Merged
Merged
Conversation
A coordinator test that failed its assertion hung the run instead of reporting the failure. Logging in starts a heartbeat that is a `while (true)` of delays on the coordinator's own scope rather than the test's `backgroundScope`, and `runTest` drains the scheduler once the body returns. These tests called `coordinator.teardown()` as a bare last statement, so an assertion that threw skipped it and left that loop advancing virtual time with nothing to stop it. Wrap each body in a `tornDown` helper that tears down in a `finally`. Breaking one assertion in ViewerStateStreamTest shows the difference: unwrapped it was still spinning when killed at 240s with nothing reported, wrapped it fails in 14s naming all three affected tests. GroupChatRoutingTest and ChatHistoryHydrationTest already did this and document why; this brings the remaining four files onto the same footing. ChatCoordinatorTeardownTest is left alone — it calls teardown() as its subject and never logs in, so no heartbeat is running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A coordinator test that failed its assertion hung the run instead of reporting the failure.
RealChatCoordinator.onUserLoggedInends withstartHeartbeat { syncFeeds() }, awhile (true)of delays on the coordinator's ownCoroutineScope. That scope is not the test'sbackgroundScope, so it outlives the test body, andrunTestdrains the scheduler once the body returns. These tests calledcoordinator.teardown()as a bare last statement, so an assertion that threw skipped it and left that loop advancing virtual time with nothing to stop it.Each body now runs inside a
tornDownhelper that tears down in afinally.Evidence
Same deliberate break (
exactly = 1toexactly = 99) inViewerStateStreamTest, run twice:Module suite green at 13s.
Scope
25 tests across four files.
GroupChatRoutingTestandChatHistoryHydrationTestalready used this shape and document the hazard in KDoc — this brings the rest onto the same footing rather than inventing a pattern.ChatCoordinatorTeardownTestis deliberately untouched: it callsteardown()as the subject under test and never logs in, so no heartbeat is running. The one deliberate mid-bodyteardown()inChatCoordinatorEventsTest's re-login test is also preserved — only its trailing call became thefinally.Tests only; no production code.
Why separately from #1511
Found while debugging a hang in a new test on that branch. It is a pre-existing hazard in tests unrelated to that fix, so it reviews better on its own.