Skip to content

Commit e7e3972

Browse files
committed
fixes flaky test when deleting all data event repository
1 parent 185939d commit e7e3972

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

attributed-metrics/attributed-metrics-impl/src/test/java/com/duckduckgo/app/attributed/metrics/store/RealEventRepositoryTest.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ class RealEventRepositoryTest {
4444

4545
@Before
4646
fun setup() {
47-
db =
48-
Room
49-
.inMemoryDatabaseBuilder(
50-
InstrumentationRegistry.getInstrumentation().targetContext,
51-
AttributedMetricsDatabase::class.java,
52-
).build()
47+
db = Room.inMemoryDatabaseBuilder(
48+
InstrumentationRegistry.getInstrumentation().targetContext,
49+
AttributedMetricsDatabase::class.java,
50+
).allowMainThreadQueries().build()
5351
eventDao = db.eventDao()
5452
testDateProvider = FakeAttributedMetricsDateUtils(LocalDate.of(2025, 10, 3))
5553
repository =
@@ -157,7 +155,7 @@ class RealEventRepositoryTest {
157155
repository.deleteAllEvents()
158156

159157
// Wait for the background coroutine to complete
160-
advanceUntilIdle()
158+
coroutineTestRule.testScope.advanceUntilIdle()
161159

162160
val remainingEvents = eventDao.getEventsByNameAndTimeframe("test_event", "2025-09-03", "2025-10-03")
163161
assert(remainingEvents.isEmpty())

0 commit comments

Comments
 (0)