feat: refactor file paths to use %LOCALAPPDATA% for user data and logs (#829)

This commit is contained in:
Jeffrey
2026-10-17 00:17:44 +02:00
committed by GitHub
parent 25c3999be5
commit dd1f934174
6 changed files with 21 additions and 15 deletions
+2 -2
View File
@@ -69,11 +69,11 @@ Describe 'New-RegistrySettingsBackup' {
$script:RegistryBackupsPath = Join-Path $TestDrive 'Backups'
$script:Features = @{ Feature = [PSCustomObject]@{ FeatureId = 'Feature'; RegistryKey = 'feature.reg' } }
Mock Get-RegistryBackupPayload { @{ Version = '1.0' } }
Mock Save-ToFile { $true }
Mock Write-Host {}
}
It 'returns null and does not write when no selected feature has registry data' {
Mock Save-ToFile { $true }
$script:Features.Feature.RegistryKey = ''
New-RegistrySettingsBackup -ActionableKeys @('Feature') | Should -BeNullOrEmpty
@@ -85,7 +85,7 @@ Describe 'New-RegistrySettingsBackup' {
$result | Should -Match 'Win11Debloat-RegistryBackup-\d{8}_\d{6}\.json$'
Test-Path -LiteralPath $script:RegistryBackupsPath | Should -BeTrue
Should -Invoke Save-ToFile -Times 1 -Exactly -ParameterFilter { $FilePath -eq $result -and $MaxDepth -eq 25 }
(Get-Content -LiteralPath $result -Raw | ConvertFrom-Json).Version | Should -Be '1.0'
}
It 'throws when persistence reports failure' {
+8
View File
@@ -18,6 +18,14 @@ BeforeAll {
}
Describe 'Save-ToFile' {
It 'creates the destination directory on first use' {
$path = Join-Path $TestDrive 'UserData\LastUsedSettings.json'
Save-ToFile -Config @{ Setting = $true } -FilePath $path | Should -BeTrue
(Get-Content -LiteralPath $path -Raw | ConvertFrom-Json).Setting | Should -BeTrue
}
It 'reports the write error and returns false when persistence fails' {
Mock Set-Content { throw [System.IO.IOException]::new('Disk is full') }
Mock Write-Error {}