@@ -2,6 +2,7 @@ Import-Module PSScriptAnalyzer
2
2
$directory = Split-Path - Parent $MyInvocation.MyCommand.Path
3
3
$testManifestPath = Join-Path $directory " TestManifest"
4
4
$testManifestBadFunctionsWildcardPath = " ManifestBadFunctionsWildcard.psd1"
5
+ $testManifestBadFunctionsWildcardInArrayPath = " ManifestBadFunctionsWildcardInArray.psd1"
5
6
$testManifestBadFunctionsNullPath = " ManifestBadFunctionsNull.psd1"
6
7
$testManifestBadCmdletsWildcardPath = " ManifestBadCmdletsWildcard.psd1"
7
8
$testManifestBadAliasesWildcardPath = " ManifestBadAliasesWildcard.psd1"
@@ -35,31 +36,42 @@ Describe "UseManifestExportFields" {
35
36
It " detects FunctionsToExport with wildcard" {
36
37
$results = Run- PSScriptAnalyzerRule $testManifestBadFunctionsWildcardPath
37
38
$results.Count | Should be 1
38
- $results [0 ].Extent.Text | Should be " FunctionsToExport = '*'"
39
+ $results [0 ].Extent.Text | Should be " '*'"
39
40
}
40
41
41
42
It " detects FunctionsToExport with null" {
42
43
$results = Run- PSScriptAnalyzerRule $testManifestBadFunctionsNullPath
43
44
$results.Count | Should be 1
44
- $results [0 ].Extent.Text | Should be ' FunctionsToExport = $null'
45
+ $results [0 ].Extent.Text | Should be ' $null'
45
46
}
46
47
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
+
47
59
It " detects CmdletsToExport with wildcard" {
48
60
$results = Run- PSScriptAnalyzerRule $testManifestBadCmdletsWildcardPath
49
61
$results.Count | Should be 1
50
- $results [0 ].Extent.Text | Should be " CmdletsToExport = '*'"
62
+ $results [0 ].Extent.Text | Should be " '*'"
51
63
}
52
64
53
65
It " detects AliasesToExport with wildcard" {
54
66
$results = Run- PSScriptAnalyzerRule $testManifestBadAliasesWildcardPath
55
67
$results.Count | Should be 1
56
- $results [0 ].Extent.Text | Should be " AliasesToExport = '*'"
68
+ $results [0 ].Extent.Text | Should be " '*'"
57
69
}
58
70
59
71
It " detects VariablesToExport with wildcard" {
60
72
$results = Run- PSScriptAnalyzerRule $testManifestBadVariablesWildcardPath
61
73
$results.Count | Should be 1
62
- $results [0 ].Extent.Text | Should be " VariablesToExport = '*'"
74
+ $results [0 ].Extent.Text | Should be " '*'"
63
75
}
64
76
65
77
It " detects all the *ToExport violations" {
0 commit comments