mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-23 16:12:08 +00:00
Improve registry backup safety and add optional backup skipping (#710)
This commit is contained in:
@@ -28,4 +28,109 @@ Describe 'Get-RebootFeatureLabels' {
|
||||
$result | Should -Contain 'Undo feature'
|
||||
$result | Should -Not -Contain 'No reboot'
|
||||
}
|
||||
|
||||
It 'uses the regular label for a forward-only selection' {
|
||||
$script:Params = @{ ApplyFeature = $true }
|
||||
$script:UndoParams = @{}
|
||||
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 1
|
||||
$result | Should -Contain 'Apply feature'
|
||||
}
|
||||
|
||||
It 'falls back to the regular label when an undo selection has no undo label' {
|
||||
$script:Params = @{}
|
||||
$script:UndoParams = @{ ApplyFeature = $true }
|
||||
$script:Features.ApplyFeature.UndoLabel = $null
|
||||
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 1
|
||||
$result | Should -Contain 'Apply feature'
|
||||
}
|
||||
|
||||
It 'falls back to the regular label when the feature has no UndoLabel property' {
|
||||
$script:Params = @{}
|
||||
$script:UndoParams = @{ MissingUndoLabelFeature = $true }
|
||||
$script:Features.MissingUndoLabelFeature = [PSCustomObject]@{
|
||||
RequiresReboot = $true
|
||||
Label = 'Feature without undo label'
|
||||
}
|
||||
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 1
|
||||
$result | Should -Contain 'Feature without undo label'
|
||||
}
|
||||
|
||||
It 'returns no labels when there are no selected parameters' {
|
||||
$script:Params = @{}
|
||||
$script:UndoParams = @{}
|
||||
|
||||
@(Get-RebootFeatureLabels).Count | Should -Be 0
|
||||
}
|
||||
|
||||
It 'keeps one label for each distinct reboot feature when their labels match' {
|
||||
$script:Params = @{
|
||||
FirstMatchingLabelFeature = $true
|
||||
SecondMatchingLabelFeature = $true
|
||||
}
|
||||
$script:UndoParams = @{}
|
||||
$script:Features.FirstMatchingLabelFeature = [PSCustomObject]@{
|
||||
RequiresReboot = $true
|
||||
Label = 'Shared label'
|
||||
UndoLabel = 'Undo first shared label'
|
||||
}
|
||||
$script:Features.SecondMatchingLabelFeature = [PSCustomObject]@{
|
||||
RequiresReboot = $true
|
||||
Label = 'Shared label'
|
||||
UndoLabel = 'Undo second shared label'
|
||||
}
|
||||
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 2
|
||||
@($result | Where-Object { $_ -eq 'Shared label' }).Count | Should -Be 2
|
||||
}
|
||||
|
||||
It 'accepts truthy reboot flags' {
|
||||
$script:Params = @{
|
||||
StringRebootFeature = $true
|
||||
NumericRebootFeature = $true
|
||||
}
|
||||
$script:UndoParams = @{}
|
||||
$script:Features.StringRebootFeature = [PSCustomObject]@{
|
||||
RequiresReboot = 'true'
|
||||
Label = 'String reboot'
|
||||
UndoLabel = 'Undo string reboot'
|
||||
}
|
||||
$script:Features.NumericRebootFeature = [PSCustomObject]@{
|
||||
RequiresReboot = 1
|
||||
Label = 'Numeric reboot'
|
||||
UndoLabel = 'Undo numeric reboot'
|
||||
}
|
||||
|
||||
$result = @(Get-RebootFeatureLabels)
|
||||
|
||||
$result | Should -HaveCount 2
|
||||
$result | Should -Contain 'String reboot'
|
||||
$result | Should -Contain 'Numeric reboot'
|
||||
}
|
||||
|
||||
It 'excludes unknown, non-reboot, and blank-label selections' {
|
||||
$script:Params = @{
|
||||
UnknownFeature = $true
|
||||
NoRebootFeature = $true
|
||||
BlankLabelFeature = $true
|
||||
}
|
||||
$script:UndoParams = @{}
|
||||
$script:Features.BlankLabelFeature = [PSCustomObject]@{
|
||||
RequiresReboot = $true
|
||||
Label = ' '
|
||||
UndoLabel = $null
|
||||
}
|
||||
|
||||
@(Get-RebootFeatureLabels).Count | Should -Be 0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user