From 3e8d522aa8f5c3bef96f84559c32ba8a08b3b0d1 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Mon, 30 Sep 2024 08:42:40 +0200 Subject: [PATCH] Initialize DataStore with `TestScope.backgroundScope` in unit tests Fixes #1647 --- .../core/data/repository/OfflineFirstNewsRepositoryTest.kt | 2 +- .../core/data/repository/OfflineFirstTopicsRepositoryTest.kt | 2 +- .../core/data/repository/OfflineFirstUserDataRepositoryTest.kt | 2 +- .../nowinandroid/core/datastore/NiaPreferencesDataSourceTest.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt index 47c3996c4..413147f0e 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt @@ -73,7 +73,7 @@ class OfflineFirstNewsRepositoryTest { @Before fun setup() { niaPreferencesDataSource = NiaPreferencesDataSource( - tmpFolder.testUserPreferencesDataStore(testScope), + tmpFolder.testUserPreferencesDataStore(testScope.backgroundScope), ) newsResourceDao = TestNewsResourceDao() topicDao = TestTopicDao() diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt index 3bd314eae..be41c86f2 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt @@ -60,7 +60,7 @@ class OfflineFirstTopicsRepositoryTest { topicDao = TestTopicDao() network = TestNiaNetworkDataSource() niaPreferences = NiaPreferencesDataSource( - tmpFolder.testUserPreferencesDataStore(testScope), + tmpFolder.testUserPreferencesDataStore(testScope.backgroundScope), ) synchronizer = TestSynchronizer(niaPreferences) diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt index 422e2cfb7..88b3251e5 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt @@ -51,7 +51,7 @@ class OfflineFirstUserDataRepositoryTest { @Before fun setup() { niaPreferencesDataSource = NiaPreferencesDataSource( - tmpFolder.testUserPreferencesDataStore(testScope), + tmpFolder.testUserPreferencesDataStore(testScope.backgroundScope), ) subject = OfflineFirstUserDataRepository( diff --git a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSourceTest.kt b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSourceTest.kt index 433812808..ba1706461 100644 --- a/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSourceTest.kt +++ b/core/datastore/src/test/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSourceTest.kt @@ -40,7 +40,7 @@ class NiaPreferencesDataSourceTest { @Before fun setup() { subject = NiaPreferencesDataSource( - tmpFolder.testUserPreferencesDataStore(testScope), + tmpFolder.testUserPreferencesDataStore(testScope.backgroundScope), ) }