mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-11-25 23:16:15 +01:00
fix(registry-restore): continue restoring remaining keys when one fails (#837)
Co-authored-by: Jeffrey <9938813+Raphire@users.noreply.github.com>
This commit is contained in:
co-authored by
Jeffrey
parent
e6184a2597
commit
f39885f6f2
@@ -195,6 +195,35 @@ Describe 'Restore-RegistryBackupState' {
|
||||
|
||||
Should -Invoke Restore-RegistryKeySnapshot -Times 0 -Exactly
|
||||
}
|
||||
|
||||
It 'continues restoring remaining snapshots when one fails, then reports the failure' {
|
||||
Mock Write-Warning {}
|
||||
Mock Restore-RegistryKeySnapshot { throw 'access denied' } -ParameterFilter { $Snapshot.Path -eq 'HKEY_CURRENT_USER\Software\One' }
|
||||
|
||||
{ Restore-RegistryBackupState -Backup $script:backup } |
|
||||
Should -Throw 'Registry restore finished with 1 failed key(s). See console for details.'
|
||||
|
||||
Should -Invoke Restore-RegistryKeySnapshot -Times 2 -Exactly
|
||||
Should -Invoke Restore-RegistryKeySnapshot -Times 1 -Exactly -ParameterFilter { $Snapshot.Path -eq 'HKEY_CURRENT_USER\Software\Two' }
|
||||
}
|
||||
|
||||
It 'rejects a malformed backup before restoring any snapshot' {
|
||||
$script:backup.RegistryKeys = @(
|
||||
[PSCustomObject]@{ Path = 'HKEY_CURRENT_USER\Software\One'; Exists = $true; Values = @(); SubKeys = @() }
|
||||
[PSCustomObject]@{
|
||||
Path = 'HKEY_CURRENT_USER\Software\Two'; Exists = $true; Values = @()
|
||||
SubKeys = @(
|
||||
[PSCustomObject]@{ Path = 'HKEY_CURRENT_USER\Software\Two\Child'; Exists = $true; Values = @(); SubKeys = @() }
|
||||
[PSCustomObject]@{ Path = 'HKEY_CURRENT_USER\Software\Two\Child'; Exists = $true; Values = @(); SubKeys = @() }
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
{ Restore-RegistryBackupState -Backup $script:backup } |
|
||||
Should -Throw '*duplicate or unsupported registry child path*'
|
||||
|
||||
Should -Invoke Restore-RegistryKeySnapshot -Times 0 -Exactly
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Restore executable warning dialog' {
|
||||
|
||||
Reference in New Issue
Block a user