Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 0d77cf1

Browse files
throwaway774alerickson
authored andcommitted
Throw error when Test-ModuleManifest fails in Update-ModuleManifest
1 parent ab60ff8 commit 0d77cf1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Tests/PSGetUpdateModuleManifest.Tests.ps1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,25 @@ Describe PowerShell.PSGet.UpdateModuleManifest -Tags 'BVT','InnerLoop' {
686686
-expectedFullyQualifiedErrorId "InvalidPackageManagementProviders,Update-ModuleManifest"
687687
}
688688

689+
# Purpose: Validate Update-ModuleManifest will throw errors when an invalid RootModule is provided
690+
#
691+
# Action:
692+
# Update-ModuleManifest -Path [Path] -RootModule [InvalidRootModule]
693+
#
694+
# Expected Result: Update-ModuleManifest should throw errors about the invalid RootModule
695+
#
696+
It UpdateModuleManifestWithInvalidRootModule {
697+
698+
New-ModuleManifest -path $script:testManifestPath
699+
700+
$InvalidRootModule = "\/"
701+
AssertFullyQualifiedErrorIdEquals -scriptblock {Update-ModuleManifest -Path $script:testManifestPath -RootModule $InvalidRootModule} `
702+
-expectedFullyQualifiedErrorId "UpdateManifestFileFail,Update-ModuleManifest"
703+
704+
$newModuleInfo = Test-ModuleManifest -Path $script:testManifestPath
705+
Assert ($newModuleInfo.RootModule -contains $InvalidRootModule -eq $False) 'Module Manifest should not contain an invalid root module'
706+
}`
707+
-Skip:$($PSVersionTable.PSVersion -lt '5.1.0')
689708

690709
# Purpose: Validate Update-ModuleManifest will throw errors if the original manifest fail the Test-ModuleManifest
691710
#
@@ -969,4 +988,4 @@ Describe PowerShell.PSGet.UpdateModuleManifest -Tags 'BVT','InnerLoop' {
969988
Assert ($newModuleInfo.CompatiblePSEditions -contains $CompatiblePSEditions[1]) "CompatiblePSEditions should include $($CompatiblePSEditions[1])"
970989
} `
971990
-Skip:$($PSVersionTable.PSVersion -lt '5.1.0')
972-
}
991+
}

src/PowerShellGet/public/psgetfunctions/Update-ModuleManifest.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ function Update-ModuleManifest
922922

923923
#Verify the new module manifest is valid
924924
$testModuleInfo = Microsoft.PowerShell.Core\Test-ModuleManifest -Path $tempPath `
925-
-Verbose:$VerbosePreference `
925+
-Verbose:$VerbosePreference ` -ErrorAction Stop
926926
}
927927
#Catch the exceptions from Test-ModuleManifest
928928
catch

0 commit comments

Comments
 (0)