@@ -2,6 +2,7 @@ Import-Module PSScriptAnalyzer
22$directory = Split-Path - Parent $MyInvocation.MyCommand.Path
33$testManifestPath = Join-Path $directory " TestManifest"
44$testManifestBadFunctionsWildcardPath = " ManifestBadFunctionsWildcard.psd1"
5+ $testManifestBadFunctionsWildcardInArrayPath = " ManifestBadFunctionsWildcardInArray.psd1"
56$testManifestBadFunctionsNullPath = " ManifestBadFunctionsNull.psd1"
67$testManifestBadCmdletsWildcardPath = " ManifestBadCmdletsWildcard.psd1"
78$testManifestBadAliasesWildcardPath = " ManifestBadAliasesWildcard.psd1"
@@ -35,31 +36,42 @@ Describe "UseManifestExportFields" {
3536 It " detects FunctionsToExport with wildcard" {
3637 $results = Run- PSScriptAnalyzerRule $testManifestBadFunctionsWildcardPath
3738 $results.Count | Should be 1
38- $results [0 ].Extent.Text | Should be " FunctionsToExport = '*'"
39+ $results [0 ].Extent.Text | Should be " '*'"
3940 }
4041
4142 It " detects FunctionsToExport with null" {
4243 $results = Run- PSScriptAnalyzerRule $testManifestBadFunctionsNullPath
4344 $results.Count | Should be 1
44- $results [0 ].Extent.Text | Should be ' FunctionsToExport = $null'
45+ $results [0 ].Extent.Text | Should be ' $null'
4546 }
4647
48+ It " detects array element containing wildcard" {
49+ $results = Run- PSScriptAnalyzerRule $testManifestBadFunctionsWildcardInArrayPath
50+ $results.Count | Should be 3
51+ $results.Where ({$_.Message -match " FunctionsToExport" }).Extent.Text | Should be " 'Get-*'"
52+ $results.Where ({$_.Message -match " CmdletsToExport" }).Extent.Text | Should be " 'Update-*'"
53+
54+ # if more than two elements contain wildcard we can show only the first one as of now.
55+ $results.Where ({$_.Message -match " VariablesToExport" }).Extent.Text | Should be " 'foo*'"
56+ }
57+
58+
4759 It " detects CmdletsToExport with wildcard" {
4860 $results = Run- PSScriptAnalyzerRule $testManifestBadCmdletsWildcardPath
4961 $results.Count | Should be 1
50- $results [0 ].Extent.Text | Should be " CmdletsToExport = '*'"
62+ $results [0 ].Extent.Text | Should be " '*'"
5163 }
5264
5365 It " detects AliasesToExport with wildcard" {
5466 $results = Run- PSScriptAnalyzerRule $testManifestBadAliasesWildcardPath
5567 $results.Count | Should be 1
56- $results [0 ].Extent.Text | Should be " AliasesToExport = '*'"
68+ $results [0 ].Extent.Text | Should be " '*'"
5769 }
5870
5971 It " detects VariablesToExport with wildcard" {
6072 $results = Run- PSScriptAnalyzerRule $testManifestBadVariablesWildcardPath
6173 $results.Count | Should be 1
62- $results [0 ].Extent.Text | Should be " VariablesToExport = '*'"
74+ $results [0 ].Extent.Text | Should be " '*'"
6375 }
6476
6577 It " detects all the *ToExport violations" {
0 commit comments