1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-07-03 08:08:48 +00:00

Fix tests

This commit is contained in:
Isira Seneviratne 2024-06-22 17:07:04 +05:30
parent 8ecd6e6b98
commit 5887438dde

View File

@ -3,7 +3,7 @@ package org.schabi.newpipe.database
import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import io.reactivex.rxjava3.core.Single
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@ -22,7 +22,6 @@ import org.schabi.newpipe.extractor.channel.ChannelInfo
import org.schabi.newpipe.extractor.stream.StreamType
import java.io.IOException
import java.time.OffsetDateTime
import kotlin.streams.toList
class FeedDAOTest {
private lateinit var db: AppDatabase
@ -94,17 +93,13 @@ class FeedDAOTest {
)
}
private fun setupUnlinkDelete(time: String) {
private fun setupUnlinkDelete(time: String) = runBlocking {
clearAndFillTables()
Single.fromCallable {
feedDAO.unlinkStreamsOlderThan(OffsetDateTime.parse(time))
}.blockingSubscribe()
Single.fromCallable {
streamDAO.deleteOrphans()
}.blockingSubscribe()
feedDAO.unlinkStreamsOlderThan(OffsetDateTime.parse(time))
streamDAO.deleteOrphans()
}
private fun clearAndFillTables() {
private suspend fun clearAndFillTables() {
db.clearAllTables()
streamDAO.insertAll(allStreams)
subscriptionDAO.insertAll(