Fix tests and CI
This commit is contained in:
parent
476ce8a7dc
commit
a0bed539a6
@ -12,6 +12,7 @@ import com.readrops.db.entities.Feed
|
|||||||
import com.readrops.db.entities.account.Account
|
import com.readrops.db.entities.account.Account
|
||||||
import com.readrops.db.entities.account.AccountType
|
import com.readrops.db.entities.account.AccountType
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.mockwebserver.MockResponse
|
import okhttp3.mockwebserver.MockResponse
|
||||||
import okhttp3.mockwebserver.MockWebServer
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
@ -37,7 +38,7 @@ class LocalRSSRepositoryTest : KoinTest {
|
|||||||
private lateinit var feeds: List<Feed>
|
private lateinit var feeds: List<Feed>
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun before() {
|
fun before() = runTest {
|
||||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||||
database = Room.inMemoryDatabaseBuilder(context, Database::class.java).build()
|
database = Room.inMemoryDatabaseBuilder(context, Database::class.java).build()
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ class LocalRSSRepositoryTest : KoinTest {
|
|||||||
mockServer.start()
|
mockServer.start()
|
||||||
val url = mockServer.url("/rss")
|
val url = mockServer.url("/rss")
|
||||||
|
|
||||||
account.id = database.accountDao().compatInsert(account).toInt()
|
account.id = database.newAccountDao().insert(account).toInt()
|
||||||
feeds = listOf(
|
feeds = listOf(
|
||||||
Feed(
|
Feed(
|
||||||
name = "feedTest",
|
name = "feedTest",
|
||||||
@ -66,17 +67,15 @@ class LocalRSSRepositoryTest : KoinTest {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
runBlocking {
|
database.newFeedDao().insert(feeds).apply {
|
||||||
database.newFeedDao().insert(feeds).run {
|
feeds.first().id = first().toInt()
|
||||||
feeds.first().id = first().toInt()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repository = LocalRSSRepository(get(), database, account)
|
repository = LocalRSSRepository(get(), database, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun synchronizeTest() = runBlocking {
|
fun synchronizeTest() = runTest {
|
||||||
val stream = TestUtils.loadResource("rss_feed.xml")
|
val stream = TestUtils.loadResource("rss_feed.xml")
|
||||||
|
|
||||||
mockServer.enqueue(
|
mockServer.enqueue(
|
||||||
@ -90,7 +89,9 @@ class LocalRSSRepositoryTest : KoinTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertTrue { result.first.items.isNotEmpty() }
|
assertTrue { result.first.items.isNotEmpty() }
|
||||||
assertTrue { database.itemDao().itemExists(result.first.items.first().guid!!, account.id) }
|
assertTrue {
|
||||||
|
database.newItemDao().itemExists(result.first.items.first().guid!!, account.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -108,6 +109,8 @@ class LocalRSSRepositoryTest : KoinTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertTrue { result.first.items.isNotEmpty() }
|
assertTrue { result.first.items.isNotEmpty() }
|
||||||
assertTrue { database.itemDao().itemExists(result.first.items.first().guid!!, account.id) }
|
assertTrue {
|
||||||
|
database.newItemDao().itemExists(result.first.items.first().guid!!, account.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -66,7 +66,7 @@ class SyncAnalyzerTest {
|
|||||||
isNotificationEnabled = i % 2 == 0
|
isNotificationEnabled = i % 2 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
database.feedDao().insert(feed).subscribe()
|
database.newFeedDao().insert(feed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class SyncAnalyzerTest {
|
|||||||
assertEquals("caseOneElementEveryWhere", notificationContent.content)
|
assertEquals("caseOneElementEveryWhere", notificationContent.content)
|
||||||
assertEquals("feed 1", notificationContent.title)
|
assertEquals("feed 1", notificationContent.title)
|
||||||
assertTrue(notificationContent.largeIcon != null)
|
assertTrue(notificationContent.largeIcon != null)
|
||||||
assertTrue(notificationContent.accountId!! > 0)
|
assertTrue(notificationContent.accountId > 0)
|
||||||
|
|
||||||
database.newItemDao().delete(item)
|
database.newItemDao().delete(item)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user