mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
string. If the string was a uri with spaces, ToString() doesn't return the escaped version. The AbsoluteUri property should be used instead which returns an escaped absolute uri (if valid). Also renamed TestModuleManfest.ps1 to TestModuleManifest.Tests.ps1 so that it gets picked up correctly as Pester test. Since HelpInfoUri is just a string, ensure it is a valid absolute uri and escaped correctly whereas before it was just an opaque string that wasn't validated.
31 lines
1.3 KiB
PowerShell
31 lines
1.3 KiB
PowerShell
Import-Module $PSScriptRoot\..\..\Common\Test.Helpers.psm1
|
|
|
|
Describe "New-ModuleManifest tests" -tags "CI" {
|
|
BeforeEach {
|
|
New-Item -ItemType Directory -Path testdrive:/module
|
|
$testModulePath = "testdrive:/module/test.psd1"
|
|
}
|
|
|
|
AfterEach {
|
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue testdrive:/module
|
|
}
|
|
|
|
It "Uris with spaces are allowed and escaped correctly" {
|
|
$testUri = [Uri]"http://foo.com/hello world"
|
|
$absoluteUri = $testUri.AbsoluteUri
|
|
|
|
New-ModuleManifest -Path $testModulePath -ProjectUri $testUri -LicenseUri $testUri -IconUri $testUri -HelpInfoUri $testUri
|
|
$module = Test-ModuleManifest -Path $testModulePath
|
|
$module.HelpInfoUri | Should BeExactly $absoluteUri
|
|
$module.PrivateData.PSData.IconUri | Should BeExactly $absoluteUri
|
|
$module.PrivateData.PSData.LicenseUri | Should BeExactly $absoluteUri
|
|
$module.PrivateData.PSData.ProjectUri | Should BeExactly $absoluteUri
|
|
}
|
|
|
|
It "Relative URIs are not allowed" {
|
|
$testUri = [Uri]"../foo"
|
|
|
|
{ New-ModuleManifest -Path $testModulePath -ProjectUri $testUri -LicenseUri $testUri -IconUri $testUri } | ShouldBeErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.NewModuleManifestCommand"
|
|
}
|
|
}
|