Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Oct 16, 2024
1 parent 710b1e5 commit e16f39a
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 13 deletions.
Empty file added collect_app/.attach_pid25568
Empty file.
Empty file added collect_app/.attach_pid28460
Empty file.
Empty file added collect_app/.attach_pid29559
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ class FormUriActivityTest {
).build()
)

changeLock.lock()
changeLock.tryLock()
val scenario = launcherRule.launchForResult<FormUriActivity>(getBlankFormIntent(project.uuid, form.dbId))
fakeScheduler.flush()

Expand Down Expand Up @@ -1093,7 +1093,7 @@ class FormUriActivityTest {
.build()
)

changeLock.lock()
changeLock.tryLock()
val scenario = launcherRule.launchForResult<FormUriActivity>(getSavedIntent(project.uuid, instance.dbId))
fakeScheduler.flush()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FormsDataServiceTest {
val isSyncing = formsDataService.isSyncing(project.uuid)

val changeLock = changeLockProvider.create(project.uuid).formsLock as BooleanChangeLock
changeLock.lock()
changeLock.tryLock()

isSyncing.recordValues { projectValues ->
formsDataService.downloadUpdates(project.uuid)
Expand All @@ -131,7 +131,7 @@ class FormsDataServiceTest {
val isSyncing = formsDataService.isSyncing(project.uuid)

val changeLock = changeLockProvider.create(project.uuid).formsLock as BooleanChangeLock
changeLock.lock()
changeLock.tryLock()

isSyncing.recordValues { projectValues ->
formsDataService.matchFormsWithServer(project.uuid)
Expand All @@ -150,7 +150,7 @@ class FormsDataServiceTest {
@Test
fun `matchFormsWithServer() returns false when change lock is locked`() {
val changeLock = changeLockProvider.create(project.uuid).formsLock as BooleanChangeLock
changeLock.lock()
changeLock.tryLock()

assertThat(formsDataService.matchFormsWithServer(project.uuid), equalTo(false))
}
Expand Down Expand Up @@ -225,7 +225,7 @@ class FormsDataServiceTest {
val isSyncing = formsDataService.isSyncing(project.uuid)

val changeLock = changeLockProvider.create(project.uuid).formsLock as BooleanChangeLock
changeLock.lock()
changeLock.tryLock()

isSyncing.recordValues { projectValues ->
formsDataService.update(project.uuid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ServerFormUseCasesTest {
val changeLock = BooleanChangeLock()
val formDownloader = mock<FormDownloader>()

changeLock.lock()
changeLock.tryLock()

val serverForm =
ServerFormDetails("", "", "", "", "", false, true, ManifestFile("", emptyList()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class InstancesDataServiceTest {

@Test
fun `instances should not be deleted if the instances database is locked`() {
(projectDependencyModule.instancesLock as BooleanChangeLock).lock()
(projectDependencyModule.instancesLock as BooleanChangeLock).tryLock()
val result = instancesDataService.deleteInstances("projectId", longArrayOf(1))
assertThat(result, equalTo(false))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ProjectDeleterTest {
@Test
fun `If there are running background jobs that use blank forms the project should not be deleted`() {
val formChangeLock = BooleanChangeLock().apply {
lock()
tryLock()
}
whenever(changeLockProvider.getFormLock(any())).thenReturn(formChangeLock)

Expand All @@ -166,7 +166,7 @@ class ProjectDeleterTest {
@Test
fun `If there are running background jobs that use saved forms the project should not be deleted`() {
val changeLock = BooleanChangeLock().apply {
lock()
tryLock()
}
whenever(changeLockProvider.getInstanceLock(any())).thenReturn(changeLock)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ProjectResetterTest {
saveTestInstanceFiles(currentProjectId)
setupTestInstancesDatabase(currentProjectId)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ class BooleanChangeLock : ChangeLock {
}

override fun tryLock(): Boolean {
isLocked = true
return true
if (!isLocked) {
isLocked = true
return true
} else {
return false
}
}

override fun unlock() {
Expand Down

0 comments on commit e16f39a

Please sign in to comment.