In instrumentation tests, keep incremental backups
If we request backup in several chunks, packages like 'pm@' or 'android' get backed up for each chunk, so due to incremental backups, we need to keep old data when comparing.
This commit is contained in:
parent
b47b4ade1e
commit
a586ee6b14
1 changed files with 12 additions and 0 deletions
|
@ -119,9 +119,21 @@ internal interface LargeBackupTestBase : LargeTestBase {
|
|||
coEvery {
|
||||
spyKVBackup.finishBackup()
|
||||
} answers {
|
||||
val oldMap = HashMap<String, String>()
|
||||
// @pm@ and android can get backed up multiple times (if we need more than one request)
|
||||
// so we need to keep the data it backed up before
|
||||
if (backupResult.kv.containsKey(packageName)) {
|
||||
backupResult.kv[packageName]?.forEach { (key, value) ->
|
||||
// if a key existing in new data, we use its value from new data, don't override
|
||||
if (!data.containsKey(key)) oldMap[key] = value
|
||||
}
|
||||
}
|
||||
backupResult.kv[packageName!!] = data
|
||||
.mapValues { entry -> entry.value.sha256() }
|
||||
.toMutableMap()
|
||||
.apply {
|
||||
putAll(oldMap)
|
||||
}
|
||||
|
||||
packageName = null
|
||||
data = mutableMapOf()
|
||||
|
|
Loading…
Reference in a new issue