Kiprop Victor
12/07/2021, 4:41 PMKiprop Victor
12/07/2021, 4:42 PMval expectedData = listOf(area)
val expected = PagingSource.LoadResult.Page(
data = expectedData,
prevKey = null,
nextKey = 1
)
val actual = globalAreaDao.fetchPagedGlobalAreas("%a%").load(
PagingSource.LoadParams.Refresh(
key = null,
loadSize = 2,
placeholdersEnabled = false
)
)
Truth.assertThat(expected).isEqualTo(actual)
Kiprop Victor
12/07/2021, 4:43 PMPagingSource
object?yigit
12/08/2021, 4:26 PMKiprop Victor
12/08/2021, 4:36 PMInstantTaskExecutorRule
which caused the load function not return. Also, it fails using runBlockingTest
on the mainCoroutineRule
but works for runBlocking
.Jay Barria
12/30/2021, 2:12 AMload
function not returning. This after updating to Room 2.4 (2.3 works fine). I had to @Ignore some existing tests. I tried above ☝️ solution but no luck so far.Jay Barria
12/31/2021, 6:40 PM"The PagingSource implementation generated by room-paging now
uses the queryExecutor passed through RoomDatabase.Builder, so it can
be overridden, instead of <http://Dispatchers.IO|Dispatchers.IO> previously."
I had to change the executor back to <http://Dispatchers.IO|Dispatchers.IO>.asExecutor()
to make the tests work like before.
Room
.inMemoryDatabaseBuilder(context, db)
.allowMainThreadQueries()
.setQueryExecutor(executor)
.setTransactionExecutor(executor)
Additional note: I also tried using StandardTestDispatcher().asExecutor()
which I believe is the replacement for the deprecated TestCoroutineDispatcher()
but that did not work as well.
cc: @yigit @dustinyigit
12/31/2021, 7:40 PMJay Barria
01/01/2022, 1:04 AMExecutors.newSingleThreadExecutor()
in Room 2.3 and the tests involving PgingSource load
was working fine. In Room 2.4, these tests suddenly failed, the load
function wasn't returning and causing the tests to take too long. Changing it <http://Dispatchers.IO|Dispatchers.IO>.asExecutor()
made it pass again.
Room
.inMemoryDatabaseBuilder(context, db)
.allowMainThreadQueries()
.setQueryExecutor(executor)
.setTransactionExecutor(executor)
yigit
01/01/2022, 8:05 PMJay Barria
01/02/2022, 10:48 AMnewSingleThreadExecutor
(write) and TestCoroutineDispatcher
(read) as executor made it work for me.