Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions test/powershell/engine/Module/TestModuleManifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
}

It "module manifest containing missing files returns error: <parameter>" -TestCases (
@{parameter = "RequiredAssemblies"; error = "Modules_InvalidRequiredAssembliesInModuleManifest"},
@{parameter = "NestedModules"; error = "Modules_InvalidNestedModuleinModuleManifest"},
@{parameter = "RequiredModules"; error = "Modules_InvalidRequiredModulesinModuleManifest"},
@{parameter = "FileList"; error = "Modules_InvalidFilePathinModuleManifest"},
@{parameter = "ModuleList"; error = "Modules_InvalidModuleListinModuleManifest"},
@{parameter = "TypesToProcess"; error = "Modules_InvalidManifest"},
@{parameter = "FormatsToProcess"; error = "Modules_InvalidManifest"},
@{parameter = "RootModule"; error = "Modules_InvalidRootModuleInModuleManifest"},
@{parameter = "ScriptsToProcess"; error = "Modules_InvalidManifest"}
@{parameter = "RequiredAssemblies"; errorId = "Modules_InvalidRequiredAssembliesInModuleManifest"},
@{parameter = "NestedModules"; errorId = "Modules_InvalidNestedModuleinModuleManifest"},
@{parameter = "RequiredModules"; errorId = "Modules_InvalidRequiredModulesinModuleManifest"},
@{parameter = "FileList"; errorId = "Modules_InvalidFilePathinModuleManifest"},
@{parameter = "ModuleList"; errorId = "Modules_InvalidModuleListinModuleManifest"},
@{parameter = "TypesToProcess"; errorId = "Modules_InvalidManifest"},
@{parameter = "FormatsToProcess"; errorId = "Modules_InvalidManifest"},
@{parameter = "RootModule"; errorId = "Modules_InvalidRootModuleInModuleManifest"},
@{parameter = "ScriptsToProcess"; errorId = "Modules_InvalidManifest"}
) {

param ($parameter, $error)
param ($parameter, $errorId)

New-Item -ItemType Directory -Path testdrive:/module/foo > $null
New-Item -ItemType File -Path testdrive:/module/foo/bar.psm1 > $null

$args = @{$parameter = "doesnotexist.psm1"}
New-ModuleManifest -Path $testModulePath @args
[string]$errorId = "$error,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
$fullyQualifiedErrorId = "$errorId,Microsoft.PowerShell.Commands.TestModuleManifestCommand"

{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId $errorId
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId $fullyQualifiedErrorId
}

It "module manifest containing valid unprocessed rootmodule file type succeeds: <rootModuleValue>" -TestCases (
Expand Down Expand Up @@ -81,14 +81,15 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
}

It "module manifest containing valid processed empty rootmodule file type fails: <rootModuleValue>" -TestCases (
@{rootModuleValue = "foo.cdxml"; error = "System.Xml.XmlException"} # fails when cmdlet tries to read it as XML
@{rootModuleValue = "foo.cdxml"; errorId = "System.Xml.XmlException"} # fails when cmdlet tries to read it as XML
) {

param($rootModuleValue, $error)
param($rootModuleValue, $errorId)

New-Item -ItemType File -Path testdrive:/module/$rootModuleValue > $null
New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId "$error,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
$fullyQualifiedErrorId = "$errorId,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId $fullyQualifiedErrorId
}

It "module manifest containing empty rootmodule succeeds: <rootModuleValue>" -TestCases (
Expand All @@ -105,25 +106,27 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
}

It "module manifest containing invalid rootmodule returns error: <rootModuleValue>" -TestCases (
@{rootModuleValue = "foo.psd1"; error = "Modules_InvalidManifest"}
@{rootModuleValue = "foo.psd1"; errorId = "Modules_InvalidManifest"}
) {

param($rootModuleValue, $error)
param($rootModuleValue, $errorId)

New-Item -ItemType File -Path testdrive:/module/$rootModuleValue > $null

New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId "$error,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
$fullyQualifiedErrorId = "$errorId,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId $fullyQualifiedErrorId
}

It "module manifest containing non-existing rootmodule returns error: <rootModuleValue>" -TestCases (
@{rootModuleValue = "doesnotexist.psm1"; error = "Modules_InvalidRootModuleInModuleManifest"}
@{rootModuleValue = "doesnotexist.psm1"; errorId = "Modules_InvalidRootModuleInModuleManifest"}
) {

param($rootModuleValue, $error)
param($rootModuleValue, $errorId)

New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId "$error,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
$fullyQualifiedErrorId = "$errorId,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
{ Test-ModuleManifest -Path $testModulePath -ErrorAction Stop } | Should -Throw -ErrorId $fullyQualifiedErrorId
}

It "module manifest containing nested module gets returned: <variation>" -TestCases (
Expand Down Expand Up @@ -262,4 +265,3 @@ Describe "Test-ModuleManifest Performance bug followup" -tags "CI" {
}
}
}