Skip to content

Commit

Permalink
Fix race condition in Flow test
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Melchior committed Dec 20, 2023
1 parent a651b4a commit 84a8b7f
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ class RealmNotificationsTests : FlowableTests {
realm.write { /* Do nothing */ }
val nextVersion = realm.version()

c1.receiveOrFail(message = "Failed to receive update event on Channel 1").let { realmChange ->
assertIs<UpdatedRealm<Realm>>(realmChange)
assertEquals(nextVersion, realmChange.realm.version())
}

val observer2 = async {
realm.asFlow().collect {
c2.send(it)
}
}

c1.receiveOrFail(message = "Failed to receive update event on Channel 1").let { realmChange ->
assertIs<UpdatedRealm<Realm>>(realmChange)
assertEquals(nextVersion, realmChange.realm.version())
}
c2.receiveOrFail(message = "Failed to receive initial event on Channel 2").let { realmChange ->
assertIs<InitialRealm<Realm>>(realmChange)
assertEquals(nextVersion, realmChange.realm.version())
Expand Down

0 comments on commit 84a8b7f

Please sign in to comment.