Skip to content

Commit f6f3309

Browse files
committed
Add tests for permutations of Severity which includes the new ParseError severity
1 parent 8443abf commit f6f3309

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,32 @@ Describe "Test Exclude And Include" {1
313313
}
314314

315315
Describe "Test Severity" {
316+
Context "Each severity can be chosen in any combination" {
317+
BeforeAll {
318+
$Severities = "ParseError","Error","Warning","Information"
319+
# end space is important
320+
$script = '$a=;ConvertTo-SecureString -Force -AsPlainText "bad practice" '
321+
$testcases = @{ Severity = "ParseError" }, @{ Severity = "Error" },
322+
@{ Severity = "Warning" }, @{ Severity = "Information" },
323+
@{ Severity = "ParseError", "Error" }, @{ Severity = "ParseError","Information" },
324+
@{ Severity = "Information", "Warning", "Error" }
325+
}
326+
327+
It "Can retrieve specific severity <severity>" -testcase $testcases {
328+
param ( $severity )
329+
$result = Invoke-ScriptAnalyzer -ScriptDefinition $script -Severity $severity
330+
if ( $severity -is [array] ) {
331+
@($result).Count | Should -Be @($severity).Count
332+
foreach ( $sev in $severity ) {
333+
$result.Severity | Should -Contain $sev
334+
}
335+
}
336+
else {
337+
$result.Severity | Should -Be $severity
338+
}
339+
}
340+
}
341+
316342
Context "When used correctly" {
317343
It "works with one argument" {
318344
$errors = Invoke-ScriptAnalyzer $directory\TestScript.ps1 -Severity Information

0 commit comments

Comments
 (0)