Skip to content

Commit

Permalink
Improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Sep 27, 2024
1 parent 2d8bafd commit b5d3996
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,38 +198,44 @@ class ProjectResetterTest {
}

@Test
fun `Reset instances does not clear instances if the instances database is locked`() {
fun `Reset instances does not clear instances and savepoints if the instances database is locked`() {
saveTestInstanceFiles(currentProjectId)
setupTestInstancesDatabase(currentProjectId)
setupTestSavepointsDatabase(currentProjectId)

(changeLockProvider.create(currentProjectId).instancesLock as BooleanChangeLock).lock()
val failedResetActions = projectResetter.reset(listOf(ProjectResetter.ResetAction.RESET_INSTANCES))
assertEquals(1, failedResetActions.size)

assertEquals(1, instancesRepositoryProvider.create(currentProjectId).all.size)
assertTestInstanceFiles(currentProjectId)
assertEquals(1, savepointsRepositoryProvider.create(currentProjectId).getAll().size)
}

@Test
fun `Reset instances clears instances for current project`() {
fun `Reset instances clears instances and savepoints for current project`() {
saveTestInstanceFiles(currentProjectId)
setupTestInstancesDatabase(currentProjectId)
setupTestSavepointsDatabase(currentProjectId)

resetAppState(listOf(ProjectResetter.ResetAction.RESET_INSTANCES))

assertEquals(0, instancesRepositoryProvider.create(currentProjectId).all.size)
assertFolderEmpty(storagePathProvider.getOdkDirPath(StorageSubdirectory.INSTANCES, currentProjectId))
assertEquals(0, savepointsRepositoryProvider.create(currentProjectId).getAll().size)
}

@Test
fun `Reset instances does not clear instances for another projects`() {
fun `Reset instances does not clear instances and savepoints for another projects`() {
saveTestInstanceFiles(anotherProjectId)
setupTestInstancesDatabase(anotherProjectId)
setupTestSavepointsDatabase(anotherProjectId)

resetAppState(listOf(ProjectResetter.ResetAction.RESET_INSTANCES))

assertEquals(1, instancesRepositoryProvider.create(anotherProjectId).all.size)
assertTestInstanceFiles(anotherProjectId)
assertEquals(1, savepointsRepositoryProvider.create(anotherProjectId).getAll().size)
}

@Test
Expand Down

0 comments on commit b5d3996

Please sign in to comment.