Skip to content

Commit

Permalink
[MOB-9235] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeruchat committed Dec 30, 2024
1 parent 33da97d commit 343becd
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,33 @@ class IterableKeychainTest {
// Verify failure handler was called
verify(mockDecryptionFailureHandler).onDecryptionFailed(migrationException)
}

@Test
fun testMigrationOnlyAttemptedOnce() {
// Create mock migrator
val mockMigrator = mock(IterableKeychainEncryptedDataMigrator::class.java)
// First check returns false, subsequent checks return true
`when`(mockMigrator.isMigrationCompleted())
.thenReturn(false) // first call

// First initialization
keychain = IterableKeychain(
mockContext,
mockDecryptionFailureHandler,
mockMigrator
)

`when`(mockMigrator.isMigrationCompleted())
.thenReturn(true) // subsequent calls

// Second initialization
keychain = IterableKeychain(
mockContext,
mockDecryptionFailureHandler,
mockMigrator
)

// Verify attemptMigration was called exactly once
verify(mockMigrator, times(1)).attemptMigration()
}
}

0 comments on commit 343becd

Please sign in to comment.