Skip to content

Commit 3f299b6

Browse files
committed
Update SourceOfTruthWithBarrierTests to use Turbine
Signed-off-by: matt-ramotar <[email protected]>
1 parent 29c07b7 commit 3f299b6

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

store/src/commonTest/kotlin/org/mobilenativefoundation/store/store5/SourceOfTruthWithBarrierTests.kt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.mobilenativefoundation.store.store5
1717

18+
import app.cash.turbine.test
1819
import kotlinx.coroutines.CompletableDeferred
1920
import kotlinx.coroutines.ExperimentalCoroutinesApi
2021
import kotlinx.coroutines.FlowPreview
@@ -32,7 +33,6 @@ import org.mobilenativefoundation.store.store5.SourceOfTruth.WriteException
3233
import org.mobilenativefoundation.store.store5.impl.PersistentSourceOfTruth
3334
import org.mobilenativefoundation.store.store5.impl.SourceOfTruthWithBarrier
3435
import org.mobilenativefoundation.store.store5.util.InMemoryPersister
35-
import org.mobilenativefoundation.store.store5.util.assertEmitsExactly
3636
import kotlin.test.Test
3737
import kotlin.test.assertEquals
3838
import kotlin.test.assertNull
@@ -147,19 +147,20 @@ class SourceOfTruthWithBarrierTests {
147147
persister.postReadCallback = { key, value ->
148148
throw exception
149149
}
150-
assertEmitsExactly(
151-
source.reader(1, CompletableDeferred(Unit)),
152-
listOf(
150+
151+
source.reader(1, CompletableDeferred(Unit)).test {
152+
assertEquals(
153153
StoreReadResponse.Error.Exception(
154154
origin = StoreReadResponseOrigin.SourceOfTruth,
155155
error =
156-
ReadException(
157-
key = 1,
158-
cause = exception,
159-
),
156+
ReadException(
157+
key = 1,
158+
cause = exception,
159+
),
160160
),
161-
),
162-
)
161+
awaitItem()
162+
)
163+
}
163164
}
164165

165166
@Test
@@ -187,10 +188,10 @@ class SourceOfTruthWithBarrierTests {
187188
StoreReadResponse.Error.Exception(
188189
origin = StoreReadResponseOrigin.SourceOfTruth,
189190
error =
190-
ReadException(
191-
key = 1,
192-
cause = exception,
193-
),
191+
ReadException(
192+
key = 1,
193+
cause = exception,
194+
),
194195
),
195196
collected.first(),
196197
)
@@ -204,10 +205,10 @@ class SourceOfTruthWithBarrierTests {
204205
StoreReadResponse.Error.Exception(
205206
origin = StoreReadResponseOrigin.SourceOfTruth,
206207
error =
207-
ReadException(
208-
key = 1,
209-
cause = exception,
210-
),
208+
ReadException(
209+
key = 1,
210+
cause = exception,
211+
),
211212
),
212213
StoreReadResponse.Data(
213214
// this is fetcher since we are using the write API
@@ -253,11 +254,11 @@ class SourceOfTruthWithBarrierTests {
253254
StoreReadResponse.Error.Exception(
254255
origin = StoreReadResponseOrigin.SourceOfTruth,
255256
error =
256-
WriteException(
257-
key = 1,
258-
value = failValue,
259-
cause = exception,
260-
),
257+
WriteException(
258+
key = 1,
259+
value = failValue,
260+
cause = exception,
261+
),
261262
),
262263
StoreReadResponse.Data<String?>(
263264
origin = StoreReadResponseOrigin.SourceOfTruth,

0 commit comments

Comments
 (0)