diff --git a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 index a488b7e745..fd821df764 100644 --- a/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 +++ b/test/powershell/engine/Module/TestModuleManifest.Tests.ps1 @@ -32,27 +32,27 @@ Describe "Test-ModuleManifest tests" -tags "CI" { } It "module manifest containing missing files returns error: " -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: " -TestCases ( @@ -81,14 +81,15 @@ Describe "Test-ModuleManifest tests" -tags "CI" { } It "module manifest containing valid processed empty rootmodule file type fails: " -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: " -TestCases ( @@ -105,25 +106,27 @@ Describe "Test-ModuleManifest tests" -tags "CI" { } It "module manifest containing invalid rootmodule returns error: " -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: " -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: " -TestCases ( @@ -262,4 +265,3 @@ Describe "Test-ModuleManifest Performance bug followup" -tags "CI" { } } } -