mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-19 08:21:44 +00:00
[Ubuntu] Migrate tests for common tools to Pester (part 3) (#2337)
* add test for Git * Add Heroku * Add hhvm * Add Homebrew * Add Julia * Add kind * Add Kubernetes Tools * Remove kind and homebrew validate * replace capital letter * Add Leiningen * add source to Leiningen * Add Mercurial * Add conda * Add Netlify * Add packer * Add pollinate * Add Pulumi * Add Phantomjs * Add Haveged * Fix for kubectl * Fix julia installation * Add installer_script_folder env variable to run tests in brew provisioner * Add delay after reboot * Adjust pause settings
This commit is contained in:
@@ -69,4 +69,40 @@ function ShouldReturnZeroExitCode {
|
||||
|
||||
If (Get-Command -Name Add-AssertionOperator -ErrorAction SilentlyContinue) {
|
||||
Add-AssertionOperator -Name ReturnZeroExitCode -InternalName ShouldReturnZeroExitCode -Test ${function:ShouldReturnZeroExitCode}
|
||||
}
|
||||
|
||||
function ShouldMatchCommandOutput {
|
||||
Param(
|
||||
[String] $ActualValue,
|
||||
[String] $RegularExpression,
|
||||
[switch] $Negate
|
||||
)
|
||||
|
||||
$output = (Get-CommandResult $ActualValue).Output | Out-String
|
||||
[bool] $succeeded = $output -cmatch $RegularExpression
|
||||
|
||||
if ($Negate) {
|
||||
$succeeded = -not $succeeded
|
||||
}
|
||||
|
||||
$failureMessage = ''
|
||||
|
||||
if (-not $succeeded) {
|
||||
if ($Negate) {
|
||||
$failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to not match '$output', but it did match."
|
||||
}
|
||||
else {
|
||||
$failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to match '$output', but it did not match."
|
||||
}
|
||||
}
|
||||
|
||||
return [PSCustomObject] @{
|
||||
Succeeded = $succeeded
|
||||
FailureMessage = $failureMessage
|
||||
}
|
||||
}
|
||||
|
||||
If (Get-Command -Name Add-AssertionOperator -ErrorAction SilentlyContinue) {
|
||||
Add-AssertionOperator -Name ReturnZeroExitCode -InternalName ShouldReturnZeroExitCode -Test ${function:ShouldReturnZeroExitCode}
|
||||
Add-AssertionOperator -Name MatchCommandOutput -InternalName ShouldMatchCommandOutput -Test ${function:ShouldMatchCommandOutput}
|
||||
}
|
||||
Reference in New Issue
Block a user