Skip to content

Commit 15c28a6

Browse files
author
Kapil Borle
committed
Add test case for verifying valid module manifest
1 parent 2f69abf commit 15c28a6

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

Tests/Rules/AvoidUnloadableModuleOrMissingRequiredFieldInManifest.tests.ps1

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ Describe "MissingRequiredFieldModuleManifest" {
2525
$violations.Message | Should Match $missingMessage
2626
}
2727

28-
$numExpectedCorrections = 1
29-
It "has $numExpectedCorrections suggested corrections" {
30-
$violations.SuggestedCorrections.Count | Should Be $numExpectedCorrections
31-
}
28+
$numExpectedCorrections = 1
29+
It "has $numExpectedCorrections suggested corrections" {
30+
$violations.SuggestedCorrections.Count | Should Be $numExpectedCorrections
31+
}
3232

3333

34-
It "has the right suggested correction" {
35-
$expectedText = @'
34+
It "has the right suggested correction" {
35+
$expectedText = @'
3636
# Version number of this module.
3737
ModuleVersion = '1.0.0.0'
3838
'@
39-
$violations[0].SuggestedCorrections[0].Text | Should Match $expectedText
40-
Get-ExtentText $violations[0].SuggestedCorrections[0] $violationFilepath | Should Match ""
39+
$violations[0].SuggestedCorrections[0].Text | Should Match $expectedText
40+
Get-ExtentText $violations[0].SuggestedCorrections[0] $violationFilepath | Should Match ""
4141
}
4242
}
4343

@@ -52,5 +52,17 @@ ModuleVersion = '1.0.0.0'
5252
{Invoke-ScriptAnalyzer -Path $noHashtableFilepath -IncludeRule $missingMemberRuleName} | Should Not Throw
5353
}
5454
}
55+
56+
Context "Validate the contents of a .psd1 file" {
57+
It "detects a valid module manifest file" {
58+
$filepath = Join-Path $directory "TestManifest/ManifestGood.psd1"
59+
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper]::IsModuleManifest($filepath) | Should Be $true
60+
}
61+
62+
It "detects a .psd1 file which is not module manifest" {
63+
$filepath = Join-Path $directory "TestManifest/PowerShellDataFile.psd1"
64+
[Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper]::IsModuleManifest($filepath) | Should Be $false
65+
}
66+
}
5567
}
5668

0 commit comments

Comments
 (0)