mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
Kotlin
52 lines
1.7 KiB
Kotlin
package org.tasks.data
|
|
|
|
import com.natpryce.makeiteasy.MakeItEasy.with
|
|
import dagger.hilt.android.testing.HiltAndroidTest
|
|
import dagger.hilt.android.testing.UninstallModules
|
|
import org.junit.Assert.*
|
|
import org.junit.Test
|
|
import org.tasks.injection.InjectingTestCase
|
|
import org.tasks.injection.ProductionModule
|
|
import org.tasks.makers.GoogleTaskListMaker.ACCOUNT
|
|
import org.tasks.makers.GoogleTaskListMaker.REMOTE_ID
|
|
import org.tasks.makers.GoogleTaskListMaker.newGoogleTaskList
|
|
import javax.inject.Inject
|
|
|
|
@UninstallModules(ProductionModule::class)
|
|
@HiltAndroidTest
|
|
class GoogleTaskListDaoTest : InjectingTestCase() {
|
|
@Inject lateinit var googleTaskListDao: GoogleTaskListDao
|
|
|
|
@Test
|
|
fun noResultsForEmptyAccount() {
|
|
val account = GoogleTaskAccount()
|
|
account.account = "user@gmail.com"
|
|
googleTaskListDao.insert(account)
|
|
|
|
assertTrue(googleTaskListDao.getGoogleTaskFilters(account.account!!).isEmpty())
|
|
}
|
|
|
|
@Test
|
|
fun findListWithNullAccount() {
|
|
val list = newGoogleTaskList(with(REMOTE_ID, "1234"), with(ACCOUNT, null as String?))
|
|
list.id = googleTaskListDao.insert(list)
|
|
|
|
assertEquals(list, googleTaskListDao.findExistingList("1234"))
|
|
}
|
|
|
|
@Test
|
|
fun findListWithEmptyAccount() {
|
|
val list = newGoogleTaskList(with(REMOTE_ID, "1234"), with(ACCOUNT, ""))
|
|
list.id = googleTaskListDao.insert(list)
|
|
|
|
assertEquals(list, googleTaskListDao.findExistingList("1234"))
|
|
}
|
|
|
|
@Test
|
|
fun ignoreListWithAccount() {
|
|
val list = newGoogleTaskList(with(REMOTE_ID, "1234"), with(ACCOUNT, "user@gmail.com"))
|
|
googleTaskListDao.insert(list)
|
|
|
|
assertNull(googleTaskListDao.findExistingList("1234"))
|
|
}
|
|
} |