Skip to content

Commit 7a43a1f

Browse files
committed
Add repo-facing tests for UseCompatibleSyntax
1 parent abaa667 commit 7a43a1f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Tests/Rules/UseCompatibleSyntax.Tests.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,20 @@ Describe "PSUseCompatibleSyntax" {
7878
}
7979
}
8080
}
81+
82+
It "Finds incompatibilities in a script file" {
83+
$settings = @{ Rules = @{ PSUseCompatibleSyntax = @{ Enable = $true; TargetVersions = @("3.0", "4.0", "5.1", "6.0") } } }
84+
85+
$diagnostics = Invoke-ScriptAnalyzer -IncludeRule PSUseCompatibleSyntax -Path "$PSScriptRoot/CompatibilityRuleAssets/IncompatibleScript.ps1" -Settings $settings
86+
87+
$diagnostics.Count | Should -Be 5
88+
}
89+
90+
It "Ensures there are no incompatibilities in PSSA build files" {
91+
$settings = @{ Rules = @{ PSUseCompatibleSyntax = @{ Enable = $true; TargetVersions = @("3.0", "4.0", "5.1", "6.0") } } }
92+
93+
$diagnostics = Invoke-ScriptAnalyzer -IncludeRule PSUseCompatibleSyntax -Path "$PSScriptRoot/../../" -Settings $settings
94+
95+
$diagnostics.Count | Should -Be 0
96+
}
8197
}

0 commit comments

Comments
 (0)