From 8e2c8e8e8943f4a44b2b55ed14f63b4ae1b8490a Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 15 Jan 2021 13:29:41 -0600 Subject: [PATCH] Fix tests --- .../java/org/tasks/data/CaldavDaoTests.kt | 38 ------------ .../java/org/tasks/data/UpgraderDaoTests.kt | 60 +++++++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 2 +- 3 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 app/src/androidTest/java/org/tasks/data/UpgraderDaoTests.kt diff --git a/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt b/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt index 0e7ad4439..f0c853a85 100644 --- a/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt +++ b/app/src/androidTest/java/org/tasks/data/CaldavDaoTests.kt @@ -10,12 +10,7 @@ import org.junit.Assert.* import org.junit.Test import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule -import org.tasks.makers.TagDataMaker.newTagData -import org.tasks.makers.TagMaker.TAGDATA -import org.tasks.makers.TagMaker.TASK -import org.tasks.makers.TagMaker.newTag import org.tasks.makers.TaskMaker.CREATION_TIME -import org.tasks.makers.TaskMaker.ID import org.tasks.makers.TaskMaker.newTask import org.tasks.time.DateTime import javax.inject.Inject @@ -93,39 +88,6 @@ class CaldavDaoTests : InjectingTestCase() { checkOrder(null, task.id) } - @Test - fun getCaldavTasksWithTags() = runBlocking { - val task = newTask(with(ID, 1L)) - taskDao.createNew(task) - val one = newTagData() - val two = newTagData() - tagDataDao.createNew(one) - tagDataDao.createNew(two) - tagDao.insert(newTag(with(TASK, task), with(TAGDATA, one))) - tagDao.insert(newTag(with(TASK, task), with(TAGDATA, two))) - caldavDao.insert(CaldavTask(task.id, "calendar")) - assertEquals(listOf(task.id), caldavDao.getTasksWithTags()) - } - - @Test - fun ignoreNonCaldavTaskWithTags() = runBlocking { - val task = newTask(with(ID, 1L)) - taskDao.createNew(task) - val tag = newTagData() - tagDataDao.createNew(tag) - tagDao.insert(newTag(with(TASK, task), with(TAGDATA, tag))) - assertTrue(caldavDao.getTasksWithTags().isEmpty()) - } - - @Test - fun ignoreCaldavTaskWithoutTags() = runBlocking { - val task = newTask(with(ID, 1L)) - taskDao.createNew(task) - tagDataDao.createNew(newTagData()) - caldavDao.insert(CaldavTask(task.id, "calendar")) - assertTrue(caldavDao.getTasksWithTags().isEmpty()) - } - @Test fun noResultsForEmptyAccounts() = runBlocking { val caldavAccount = CaldavAccount() diff --git a/app/src/androidTest/java/org/tasks/data/UpgraderDaoTests.kt b/app/src/androidTest/java/org/tasks/data/UpgraderDaoTests.kt new file mode 100644 index 000000000..6fe47aecb --- /dev/null +++ b/app/src/androidTest/java/org/tasks/data/UpgraderDaoTests.kt @@ -0,0 +1,60 @@ +package org.tasks.data + +import com.natpryce.makeiteasy.MakeItEasy +import com.todoroo.astrid.dao.TaskDao +import dagger.hilt.android.testing.HiltAndroidTest +import dagger.hilt.android.testing.UninstallModules +import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue +import org.junit.Test +import org.tasks.injection.InjectingTestCase +import org.tasks.injection.ProductionModule +import org.tasks.makers.TagDataMaker +import org.tasks.makers.TagMaker +import org.tasks.makers.TaskMaker +import javax.inject.Inject + +@UninstallModules(ProductionModule::class) +@HiltAndroidTest +class UpgraderDaoTests : InjectingTestCase() { + + @Inject lateinit var taskDao: TaskDao + @Inject lateinit var tagDao: TagDao + @Inject lateinit var tagDataDao: TagDataDao + @Inject lateinit var caldavDao: CaldavDao + @Inject lateinit var upgraderDao: UpgraderDao + + @Test + fun getCaldavTasksWithTags() = runBlocking { + val task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.ID, 1L)) + taskDao.createNew(task) + val one = TagDataMaker.newTagData() + val two = TagDataMaker.newTagData() + tagDataDao.createNew(one) + tagDataDao.createNew(two) + tagDao.insert(TagMaker.newTag(MakeItEasy.with(TagMaker.TASK, task), MakeItEasy.with(TagMaker.TAGDATA, one))) + tagDao.insert(TagMaker.newTag(MakeItEasy.with(TagMaker.TASK, task), MakeItEasy.with(TagMaker.TAGDATA, two))) + caldavDao.insert(CaldavTask(task.id, "calendar")) + assertEquals(listOf(task.id), upgraderDao.tasksWithTags()) + } + + @Test + fun ignoreNonCaldavTaskWithTags() = runBlocking { + val task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.ID, 1L)) + taskDao.createNew(task) + val tag = TagDataMaker.newTagData() + tagDataDao.createNew(tag) + tagDao.insert(TagMaker.newTag(MakeItEasy.with(TagMaker.TASK, task), MakeItEasy.with(TagMaker.TAGDATA, tag))) + assertTrue(upgraderDao.tasksWithTags().isEmpty()) + } + + @Test + fun ignoreCaldavTaskWithoutTags() = runBlocking { + val task = TaskMaker.newTask(MakeItEasy.with(TaskMaker.ID, 1L)) + taskDao.createNew(task) + tagDataDao.createNew(TagDataMaker.newTagData()) + caldavDao.insert(CaldavTask(task.id, "calendar")) + assertTrue(upgraderDao.tasksWithTags().isEmpty()) + } +} \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 7be53bd3e..e1c66ee85 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -679,6 +679,6 @@ 默认的开始日期 按开始日期 开始于… - 开始于:? + 开始于:? 任意开始日期 \ No newline at end of file