mirror of
https://github.com/actions/runner-images.git
synced 2025-12-11 11:37:00 +00:00
* Minor improvements * fix typos * fix brew rendering * add temp test * Implement tests * Add arguments validation * ToMarkdown() * Use before-All and helpers * Get rid of arrays * Add validation, no new nodes after header * Fix naming * add workflow * Revisit comments + tiny improvements * Fix tables * Fix html table indent * remove comment * attemp to break test - testing CI * revert breaking test * fix nitpicks
34 lines
1.1 KiB
PowerShell
34 lines
1.1 KiB
PowerShell
function ShouldBeArray([Array] $ActualValue, [Array]$ExpectedValue, [Switch] $Negate, [String] $Because) {
|
|
if ($Negate) {
|
|
throw "Negation is not supported for Should-BeArray"
|
|
}
|
|
|
|
if ($ExpectedValue.Count -eq 0) {
|
|
throw "Expected array cannot be empty. Use Should-BeNullOrEmpty instead."
|
|
}
|
|
|
|
$ExpectedValue | ForEach-Object {
|
|
if ($_.GetType() -notin @([String], [Int32])) {
|
|
throw "Only string or int arrays are supported in Should-BeArray"
|
|
}
|
|
}
|
|
|
|
$actualValueJson = $ActualValue | ConvertTo-Json
|
|
$expectedValueJson = $ExpectedValue | ConvertTo-Json
|
|
|
|
$succeeded = ($ActualValue.Count -eq $ExpectedValue.Count) -and ($actualValueJson -eq $expectedValueJson)
|
|
|
|
if (-not $succeeded) {
|
|
$failureMessage = "Expected array '$actualValueJson' to be equal to '$expectedValueJson'"
|
|
}
|
|
|
|
return [PSCustomObject]@{
|
|
Succeeded = $succeeded
|
|
FailureMessage = $failureMessage
|
|
}
|
|
}
|
|
|
|
Add-ShouldOperator -Name BeArray `
|
|
-InternalName 'ShouldBeArray' `
|
|
-Test ${function:ShouldBeArray} `
|
|
-SupportsArrayInput |