Skip to content

Commit 94ba0ec

Browse files
committed
(#3802) Add test to ensure no needless config updates
1 parent d207c12 commit 94ba0ec

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/pester-tests/chocolatey.Tests.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,30 @@ exit $error.count
280280
}
281281
}
282282

283+
# This is skipped when not run in CI because it requires a valid license
284+
Context 'Config file updates when a valid license is present' -Tag License -Skip:(-not $env:TEST_KITCHEN) {
285+
BeforeAll {
286+
Restore-ChocolateyInstallSnapshot
287+
288+
Enable-ChocolateySource -Name hermes-setup
289+
290+
Invoke-Choco install chocolatey-license-business
291+
292+
# Run once post-license-install to ensure the config file is updated with the licensed source
293+
$null = Invoke-Choco list
294+
}
295+
296+
It 'does not overwrite the config file when nothing has changed' {
297+
$originalHash = Get-FileHash -Path "$env:ChocolateyInstall/config/chocolatey.config"
298+
299+
$null = Invoke-Choco list
300+
301+
$newHash = Get-FileHash -Path "$env:ChocolateyInstall/config/chocolatey.config"
302+
303+
$originalHash.Hash | Should -BeExactly $newHash.Hash -Because 'the configuration file should not have changed between runs'
304+
}
305+
}
306+
283307
# This is skipped when not run in CI because it requires a valid license
284308
Context 'Changing licenses after modifying the Chocolatey Licensed repository' -Tag License -Skip:(-not $env:TEST_KITCHEN) {
285309
BeforeAll {

0 commit comments

Comments
 (0)