Fix instrumentation tests
Although they are very old, at least they do not break anymore in case anyone wants to execute them.
This commit is contained in:
parent
3b268ae745
commit
249cdf2ddf
3 changed files with 131 additions and 111 deletions
|
@ -3,7 +3,7 @@ package com.keylesspalace.tusky
|
|||
import androidx.room.testing.MigrationTestHelper
|
||||
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import com.keylesspalace.tusky.db.AppDatabase
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package com.keylesspalace.tusky
|
||||
|
||||
import androidx.room.Room
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.keylesspalace.tusky.db.*
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import com.keylesspalace.tusky.db.AppDatabase
|
||||
import com.keylesspalace.tusky.db.TimelineAccountEntity
|
||||
import com.keylesspalace.tusky.db.TimelineDao
|
||||
import com.keylesspalace.tusky.db.TimelineStatusEntity
|
||||
import com.keylesspalace.tusky.db.TimelineStatusWithAccount
|
||||
import com.keylesspalace.tusky.entity.Status
|
||||
import com.keylesspalace.tusky.entity.Status.Visibility.PRIVATE
|
||||
import com.keylesspalace.tusky.repository.TimelineRepository
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
|
@ -41,8 +46,10 @@ class TimelineDAOTest {
|
|||
timelineDao.insertInTransaction(status, author, reblogger)
|
||||
}
|
||||
|
||||
val resultsFromDb = timelineDao.getStatusesForAccount(setOne.first.timelineUserId,
|
||||
maxId = "21", sinceId = ignoredOne.first.serverId, limit = 10)
|
||||
val resultsFromDb = timelineDao.getStatusesForAccount(
|
||||
setOne.first.timelineUserId,
|
||||
maxId = "21", sinceId = ignoredOne.first.serverId, limit = 10
|
||||
)
|
||||
.blockingGet()
|
||||
|
||||
assertEquals(2, resultsFromDb.size)
|
||||
|
@ -97,7 +104,12 @@ class TimelineDAOTest {
|
|||
accountId = 2
|
||||
)
|
||||
|
||||
for ((status, author, reblogAuthor) in listOf(oldThisAccount, oldAnotherAccount, recentThisAccount, recentAnotherAccount)) {
|
||||
for((status, author, reblogAuthor) in listOf(
|
||||
oldThisAccount,
|
||||
oldAnotherAccount,
|
||||
recentThisAccount,
|
||||
recentAnotherAccount
|
||||
)) {
|
||||
timelineDao.insertInTransaction(status, author, reblogAuthor)
|
||||
}
|
||||
|
||||
|
@ -125,7 +137,11 @@ class TimelineDAOTest {
|
|||
makeStatus(statusId = 1)
|
||||
)
|
||||
|
||||
timelineDao.deleteRange(1, oldStatuses.last().first.serverId, oldStatuses.first().first.serverId)
|
||||
timelineDao.deleteRange(
|
||||
1,
|
||||
oldStatuses.last().first.serverId,
|
||||
oldStatuses.first().first.serverId
|
||||
)
|
||||
|
||||
for((status, author, reblogAuthor) in oldStatuses) {
|
||||
timelineDao.insertInTransaction(status, author, reblogAuthor)
|
||||
|
@ -137,7 +153,11 @@ class TimelineDAOTest {
|
|||
makeStatus(statusId = 1)
|
||||
)
|
||||
|
||||
timelineDao.deleteRange(1, newStatuses.last().first.serverId, newStatuses.first().first.serverId)
|
||||
timelineDao.deleteRange(
|
||||
1,
|
||||
newStatuses.last().first.serverId,
|
||||
newStatuses.first().first.serverId
|
||||
)
|
||||
|
||||
for((status, author, reblogAuthor) in newStatuses) {
|
||||
timelineDao.insertInTransaction(status, author, reblogAuthor)
|
||||
|
@ -204,14 +224,14 @@ class TimelineDAOTest {
|
|||
favourited = even,
|
||||
sensitive = !even,
|
||||
spoilerText = "spoier$statusId",
|
||||
visibility = Status.Visibility.PRIVATE,
|
||||
visibility = PRIVATE,
|
||||
attachments = "attachments$accountId",
|
||||
mentions = "mentions$accountId",
|
||||
application = "application$accountId",
|
||||
reblogServerId = if(reblog) (statusId * 100).toString() else null,
|
||||
reblogAccountId = reblogAuthor?.serverId,
|
||||
poll = null,
|
||||
muted = false
|
||||
pleroma = null
|
||||
)
|
||||
return Triple(status, author, reblogAuthor)
|
||||
}
|
||||
|
@ -241,7 +261,7 @@ class TimelineDAOTest {
|
|||
reblogServerId = null,
|
||||
reblogAccountId = null,
|
||||
poll = null,
|
||||
muted = false
|
||||
pleroma = null
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue