Skip to content

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Oct 29, 2024
1 parent e123557 commit 3b5f251
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.odk.collect.projects.ProjectDependencyFactory
import org.odk.collect.settings.keys.ProjectKeys
import org.odk.collect.shared.locks.ThreadSafeBooleanChangeLock
import org.odk.collect.shared.settings.InMemSettings
import java.io.File

@RunWith(AndroidJUnit4::class)
class InstancesDataServiceTest {
Expand Down Expand Up @@ -129,5 +130,7 @@ class InstancesDataServiceTest {
assertThat(remainingInstances.size, equalTo(2))
assertThat(remainingInstances.any { it.status == STATUS_COMPLETE }, equalTo(true))
assertThat(remainingInstances.any { it.status == STATUS_SUBMISSION_FAILED }, equalTo(true))
assertThat(File(remainingInstances[0].instanceFilePath).parentFile?.exists(), equalTo(true))
assertThat(File(remainingInstances[1].instanceFilePath).parentFile?.exists(), equalTo(true))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ class ProjectResetterTest {
fun `Reset instances clears instances for current project`() {
saveTestInstanceFiles(currentProjectId)
setupTestInstancesDatabase(currentProjectId)
val instancesRepository = instancesRepositoryProvider.create(currentProjectId)
val instance = instancesRepository.all[0]

resetAppState(listOf(ProjectResetter.ResetAction.RESET_INSTANCES))

assertEquals(0, instancesRepositoryProvider.create(currentProjectId).all.size)
assertFolderEmpty(storagePathProvider.getOdkDirPath(StorageSubdirectory.INSTANCES, currentProjectId))
assertEquals(0, instancesRepository.all.size)
assertEquals(false, File(instance.instanceFilePath).parentFile.exists())
}

@Test
Expand Down

0 comments on commit 3b5f251

Please sign in to comment.