Skip to content

Commit 9573b34

Browse files
committed
Fixed failing test cases
1 parent a5dea4c commit 9573b34

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

Tests/Rules/AvoidGlobalOrUnitializedVars.tests.ps1

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
Import-Module PSScriptAnalyzer
22
$globalMessage = "Found global variable 'Global:1'."
33
$globalName = "PSAvoidGlobalVars"
4-
$nonInitializedName = "PSAvoidUninitializedVariable"
4+
5+
# PSAvoidUninitializedVariable rule has been deprecated
6+
# $nonInitializedName = "PSAvoidUninitializedVariable"
7+
58
$nonInitializedMessage = "Variable 'globalVars' is not initialized. Non-global variables must be initialized. To fix a violation of this rule, please initialize non-global variables."
69
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
710
$violations = Invoke-ScriptAnalyzer $directory\AvoidGlobalOrUnitializedVars.ps1
8-
$dscResourceViolations = Invoke-ScriptAnalyzer $directory\DSCResources\MSFT_WaitForAny\MSFT_WaitForAny.psm1 | Where-Object {$_.RuleName -eq $nonInitializedName}
11+
12+
# PSAvoidUninitializedVariable rule has been deprecated
13+
# $dscResourceViolations = Invoke-ScriptAnalyzer $directory\DSCResources\MSFT_WaitForAny\MSFT_WaitForAny.psm1 | Where-Object {$_.RuleName -eq $nonInitializedName}
14+
915
$globalViolations = $violations | Where-Object {$_.RuleName -eq $globalName}
10-
$nonInitializedViolations = $violations | Where-Object {$_.RuleName -eq $nonInitializedName}
16+
17+
# PSAvoidUninitializedVariable rule has been deprecated
18+
# $nonInitializedViolations = $violations | Where-Object {$_.RuleName -eq $nonInitializedName}
19+
1120
$noViolations = Invoke-ScriptAnalyzer $directory\AvoidGlobalOrUnitializedVarsNoViolations.ps1
1221
$noGlobalViolations = $noViolations | Where-Object {$_.RuleName -eq $globalName}
13-
$noUninitializedViolations = $noViolations | Where-Object {$_.RuleName -eq $nonInitializedName}
22+
23+
# PSAvoidUninitializedVariable rule has been deprecated
24+
# $noUninitializedViolations = $noViolations | Where-Object {$_.RuleName -eq $nonInitializedName}
1425

1526
Describe "AvoidGlobalVars" {
1627
Context "When there are violations" {
1728
It "has 1 avoid using global variable violation" {
1829
$globalViolations.Count | Should Be 1
1930
}
20-
31+
32+
<#
33+
# PSAvoidUninitializedVariable rule has been deprecated
2134
It "has 4 violations for dsc resources (not counting the variables in parameters)" {
2235
$dscResourceViolations.Count | Should Be 4
2336
}
37+
#>
38+
2439

2540
It "has the correct description message" {
2641
$globalViolations[0].Message | Should Match $globalMessage
@@ -34,6 +49,8 @@ Describe "AvoidGlobalVars" {
3449
}
3550
}
3651

52+
<#
53+
# PSAvoidUninitializedVariable rule has been deprecated - Hence not a valid test case
3754
Describe "AvoidUnitializedVars" {
3855
Context "When there are violations" {
3956
It "has 5 avoid using unitialized variable violations" {
@@ -49,5 +66,6 @@ Describe "AvoidUnitializedVars" {
4966
It "returns no violations" {
5067
$noUninitializedViolations.Count | Should Be 0
5168
}
52-
}
53-
}
69+
}
70+
}
71+
#>

0 commit comments

Comments
 (0)