forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolatey#23) Add tests to handle install all
This commit adds some Pester tests to ensure that any attempts to run the choco install all command is correctly handled when targeting an alternative source. This is simply asserting that there is an error exit code, and that the correct output is displayed. Some of the new tests are specifically set to only run on Test-Kitchen, as there is the potential for changes to happen on the host machine, and we don't want to impact people.
- Loading branch information
Showing
4 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
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,30 @@ | ||
Import-Module helpers/common-helpers | ||
|
||
# This is skipped when not run in CI because it modifies the local system. | ||
Describe "Cygwin Source" -Tag Chocolatey, CygwinSource -Skip:(-not $env:TEST_KITCHEN) { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
New-ChocolateyInstallSnapshot | ||
Enable-ChocolateySource -Name hermes-setup | ||
$null = Invoke-Choco install cygwin | ||
} | ||
|
||
AfterAll { | ||
$null = Invoke-Choco uninstall cygwin --remove-dependencies | ||
Remove-ChocolateyTestInstall | ||
} | ||
|
||
Context "install all" { | ||
BeforeAll { | ||
$Output = Invoke-Choco install all --source=cygwin | ||
} | ||
|
||
It 'Exits with exit code (1)' { | ||
$Output.ExitCode | Should -Be 1 -Because $Output.String | ||
} | ||
|
||
It 'Outputs exception' { | ||
$Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -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
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,30 @@ | ||
Import-Module helpers/common-helpers | ||
|
||
# This is skipped when not run in CI because it modifies the local system. | ||
Describe "Ruby Source" -Tag Chocolatey, RubySource -Skip:(-not $env:TEST_KITCHEN) { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
New-ChocolateyInstallSnapshot | ||
Enable-ChocolateySource -Name hermes-setup | ||
$null = Invoke-Choco install ruby.portable | ||
} | ||
|
||
AfterAll { | ||
$null = Invoke-Choco uninstall ruby.portable --remove-dependencies | ||
Remove-ChocolateyTestInstall | ||
} | ||
|
||
Context "install all" { | ||
BeforeAll { | ||
$Output = Invoke-Choco install all --source=ruby | ||
} | ||
|
||
It 'Exits with exit code (1)' { | ||
$Output.ExitCode | Should -Be 1 -Because $Output.String | ||
} | ||
|
||
It 'Outputs exception' { | ||
$Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
tests/pester-tests/features/WindowsFeaturesSource.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,26 @@ | ||
Import-Module helpers/common-helpers | ||
|
||
Describe "Windows Features Source" -Tag Chocolatey, WindowsFeaturesSource { | ||
BeforeAll { | ||
Initialize-ChocolateyTestInstall | ||
New-ChocolateyInstallSnapshot | ||
} | ||
|
||
AfterAll { | ||
Remove-ChocolateyTestInstall | ||
} | ||
|
||
Context "install all" { | ||
BeforeAll { | ||
$Output = Invoke-Choco install all --source=windowsfeatures | ||
} | ||
|
||
It 'Exits with exit code (1)' { | ||
$Output.ExitCode | Should -Be 1 -Because $Output.String | ||
} | ||
|
||
It 'Outputs exception' { | ||
$Output.Lines | Should -Contain "Alternative sources do not allow the use of the 'all' package name/keyword." -Because $Output.String | ||
} | ||
} | ||
} |