be700729d6
This unifies file encoding across the inbox cmdlets to be UTF-8 without a BOM for all platforms. This is a breaking change as cmdlets on windows have a number of different encodings. This supports better interoperability with tradition Linux shells as we are using the same encoding. Validate that files are created with UTF-8 encoding without BOM Update tests to validate Encoding parameter to new type and create new tests for parameter type validation. [Breaking Change] The '-Encoding Byte' has been removed from the filesystem provider cmdlets. A new parameter '-AsByteStream' is now added to indicate that a byte stream is required as input, or output will be a stream of bytes.
54 lines
2.1 KiB
PowerShell
54 lines
2.1 KiB
PowerShell
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
|
|
}
|
|
|
|
BeforeAll {
|
|
if ($IsWindows)
|
|
{
|
|
$ExpectedManifestBytes = @(255,254,35,0,13,0,10,0)
|
|
}
|
|
else
|
|
{
|
|
$ExpectedManifestBytes = @(35,10)
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
function TestNewModuleManifestEncoding {
|
|
param ([byte[]]$expected)
|
|
New-ModuleManifest -Path $testModulePath
|
|
(Get-Content -AsByteStream -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should Be ($expected -join ',')
|
|
}
|
|
|
|
It "Verify module manifest encoding" {
|
|
|
|
# verify first line of the manifest:
|
|
# on Windows platforms - 3 characters - '#' '\r' '\n' - in UTF-16 with BOM - this should be @(255,254,35,0,13,0,10,0)
|
|
# on non-Windows platforms - 2 characters - '#' '\n' - in UTF-8 no BOM - this should be @(35,10)
|
|
TestNewModuleManifestEncoding -expected $ExpectedManifestBytes
|
|
}
|
|
|
|
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"
|
|
}
|
|
}
|