Skip to content

Commit d8b2da9

Browse files
author
Kapil Borle
committed
Add test to verify severity filter for dsc rules
1 parent 7ff2763 commit d8b2da9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,26 @@ Describe "Test Severity" {
317317
$errors = Invoke-ScriptAnalyzer $directory\TestScript.ps1 -Severity information, warning
318318
$errors.Count | Should Be 1
319319
}
320+
321+
It "works for dsc rules" {
322+
$testDataPath = [System.IO.Path]::Combine($(Split-Path $directory -Parent), `
323+
'Rules', `
324+
'DSCResources', `
325+
'MSFT_WaitForAll', `
326+
'MSFT_WaitForAll.psm1')
327+
328+
Function Get-Count {begin{$count=0} process{$count++} end{$count}}
329+
330+
Invoke-ScriptAnalyzer -Path $testDataPath -Severity Error | `
331+
Where-Object {$_.RuleName -eq "PSDSCUseVerboseMessageInDSCResource"} | `
332+
Get-Count | `
333+
Should Be 0
334+
335+
Invoke-ScriptAnalyzer -Path $testDataPath -Severity Information | `
336+
Where-Object {$_.RuleName -eq "PSDSCUseVerboseMessageInDSCResource"} | `
337+
Get-Count | `
338+
Should Be 2
339+
}
320340
}
321341

322342
Context "When used incorrectly" {

0 commit comments

Comments
 (0)