-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#2854) Pester tests to Get-ChocolateyConfigValue
Add pester tests around the functionality added by Get-ChocolateyConfigValue
- Loading branch information
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
tests/chocolatey-tests/features/ChocolateyFunctions.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# These tests install packages that exercise the Chocolatey PowerShell functions | ||
# TODO: Move some of the install tests into this file | ||
Describe 'Chocolatey PowerShell functions' { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
} | ||
|
||
Context 'Get-ChocolateyConfigValue' -ForEach @{ | ||
ConfigValues = @( | ||
@{ Name = 'addedTextValue' ; Value = 'SomeTextValue' } | ||
@{ Name = 'addedNumberValue' ; Value = 123456 } | ||
@{ Name = 'commandExecutionTimeoutSeconds' ; Value = 2795 } | ||
@{ Name = 'cacheLocation' ; Value = $null } | ||
@{ Name = 'nonExistentKey' ; Value = $null } | ||
) | ||
} -Tag Get-ChocolateyConfigValue { | ||
|
||
BeforeAll { | ||
Restore-ChocolateyInstallSnapshot | ||
|
||
foreach ($Value in $ConfigValues) { | ||
if ($null -ne $Value.Value) { | ||
Invoke-Choco config set --name $Value.Name --value $Value.Value | ||
} | ||
} | ||
|
||
$Output = Invoke-Choco install getconfig --confirm | ||
} | ||
|
||
It 'Exits with Success (0)' { | ||
$Output.ExitCode | Should -Be 0 -Because $Output.String | ||
} | ||
|
||
It 'Outputs the expected value for config entry (<Name>)' -ForEach $ConfigValues { | ||
# Trim the output as Lines is trimmed. | ||
$Output.Lines | Should -Contain "${Name}: $Value".Trim() -Because $Output.String | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<id>getconfig</id> | ||
<version>1.0.0</version> | ||
<owners>Chocolatey</owners> | ||
<title>getconfig</title> | ||
<authors>Chocolatey</authors> | ||
<copyright>Chocolatey</copyright> | ||
<tags>getconfig</tags> | ||
<description>Test package for using Get-ChocolateyConfigValue.</description> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$ErrorActionPreference = 'Stop' | ||
|
||
$ValuesToTest = @( | ||
'addedTextValue' | ||
'addedNumberValue' | ||
'commandExecutionTimeoutSeconds' | ||
'cacheLocation' | ||
'nonExistentKey' | ||
) | ||
|
||
foreach ($Value in $ValuesToTest) { | ||
$Result = Get-ChocolateyConfigValue -configKey $Value | ||
Write-Host "${Value}: $Result" | ||
} |