SecureBackup: improve error flow when backup state cannot be retrieved, and add tests.

This commit is contained in:
Benoit Marty 2023-11-20 10:00:21 +01:00
parent d352f14665
commit c07a032157
7 changed files with 147 additions and 26 deletions

View file

@ -34,6 +34,7 @@ class FakeEncryptionService : EncryptionService {
private var waitForBackupUploadSteadyStateFlow: Flow<BackupUploadState> = flowOf()
private var fixRecoveryIssuesFailure: Exception? = null
private var doesBackupExistOnServerResult: Result<Boolean> = Result.success(true)
override suspend fun enableBackups(): Result<Unit> = simulateLongTask {
return Result.success(Unit)
@ -52,8 +53,12 @@ class FakeEncryptionService : EncryptionService {
return Result.success(Unit)
}
fun givenDoesBackupExistOnServerResult(result: Result<Boolean>) {
doesBackupExistOnServerResult = result
}
override suspend fun doesBackupExistOnServer(): Result<Boolean> = simulateLongTask {
return Result.success(true)
return doesBackupExistOnServerResult
}
override suspend fun fixRecoveryIssues(recoveryKey: String): Result<Unit> = simulateLongTask {