ps/Modules/PSScriptAnalyzerTestShell.ps1

21 lines
499 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[Object[]]$Analysis,
[Parameter(Mandatory)]
[string]$ModuleName
)
$scriptAnalyzerRules = Get-ScriptAnalyzerRule
forEach ($rule in $scriptAnalyzerRules) {
It "Module $ModuleName Should Pass $rule" {
If ($Analysis.RuleName -contains $rule) {
$Analysis | Where-Object RuleName -eq $rule -OutVariable failures | Out-Default
$failures.Count | Should Be 0
}
}
}