Use new Pester syntax: -Parameter for Pester tests in engine. (#6298)

* Use new Pester syntax: -Parameter for Pester tests in engine.
This commit is contained in:
Klaudia Algiz
2018-03-14 12:13:32 -07:00
committed by Aditya Patwardhan
parent bd258a3dbc
commit 090f8761e8
38 changed files with 708 additions and 729 deletions
@@ -48,10 +48,10 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
$paths = $defaultModulePath -split [System.IO.Path]::PathSeparator
$paths.Count | Should Be 3
$paths[0].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedUserPath
$paths[1].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedSharedPath
$paths[2].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should Be $expectedSystemPath
$paths.Count | Should -Be 3
$paths[0].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedUserPath
$paths[1].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedSharedPath
$paths[2].TrimEnd([System.IO.Path]::DirectorySeparatorChar) | Should -Be $expectedSystemPath
}
It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR) {
@@ -68,10 +68,10 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
$newModulePath = & $powershell -nopro -c '$env:PSModulePath'
$paths = $newModulePath -split [System.IO.Path]::PathSeparator
$paths.Count | Should Be 3
$paths[0] | Should Be $expectedUserPath
$paths[1] | Should Be $expectedSharedPath
$paths[2] | Should Be $expectedSystemPath
$paths.Count | Should -Be 3
$paths[0] | Should -Be $expectedUserPath
$paths[1] | Should -Be $expectedSharedPath
$paths[2] | Should -Be $expectedSystemPath
} finally {
@@ -89,9 +89,9 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
$newModulePath = & $powershell -nopro -c '$env:PSModulePath'
$paths = $newModulePath -split [System.IO.Path]::PathSeparator
$paths.Count | Should Be 5
$paths -contains $fakePSHomeModuleDir | Should Be $true
$paths -contains $customeModules | Should Be $true
$paths.Count | Should -Be 5
$paths -contains $fakePSHomeModuleDir | Should -BeTrue
$paths -contains $customeModules | Should -BeTrue
}
}
@@ -24,16 +24,16 @@ Describe "New-ModuleManifest tests" -tags "CI" {
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
$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 ',')
(Get-Content -AsByteStream -Path $testModulePath -TotalCount $expected.Length) -join ',' | Should -Be ($expected -join ',')
}
It "Verify module manifest encoding" {
@@ -43,7 +43,7 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" {
New-ModuleManifest $moduleFilePath -NestedModules @($SubModulePath)
Import-Module $moduleFilePath
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -BeTrue
}
It "Test if RootModule path is <SubModulePath>" -TestCases $testCases {
@@ -51,6 +51,6 @@ Describe "Tests for paths of submodules in module manifest" -tags "CI" {
New-ModuleManifest $moduleFilePath -RootModule $SubModulePath
Import-Module $moduleFilePath
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should Be $true
(Get-Module $moduleName).ExportedCommands.Keys.Contains('TestModuleFunction') | Should -BeTrue
}
}
@@ -18,10 +18,10 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
New-ModuleManifest -NestedModules $fileList -RootModule foo\bar.psm1 -RequiredAssemblies $fileList -Path $testModulePath -TypesToProcess $fileList -FormatsToProcess $fileList -ScriptsToProcess $fileList -FileList $fileList -ModuleList $fileList
Test-Path $testModulePath | Should Be $true
Test-Path $testModulePath | Should -BeTrue
# use -ErrorAction Stop to cause test to fail if Test-ModuleManifest writes to error stream
Test-ModuleManifest -Path $testModulePath -ErrorAction Stop | Should BeOfType System.Management.Automation.PSModuleInfo
Test-ModuleManifest -Path $testModulePath -ErrorAction Stop | Should -BeOfType System.Management.Automation.PSModuleInfo
}
It "module manifest containing missing files returns error: <parameter>" -TestCases (
@@ -63,8 +63,8 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
New-Item -ItemType File -Path testdrive:/module/$rootModuleValue
New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue
$moduleManifest = Test-ModuleManifest -Path $testModulePath -ErrorAction Stop
$moduleManifest | Should BeOfType System.Management.Automation.PSModuleInfo
$moduleManifest.RootModule | Should Be $rootModuleValue
$moduleManifest | Should -BeOfType System.Management.Automation.PSModuleInfo
$moduleManifest.RootModule | Should -Be $rootModuleValue
}
It "module manifest containing valid processed empty rootmodule file type fails: <rootModuleValue>" -TestCases (
@@ -94,8 +94,8 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
New-ModuleManifest -Path $testModulePath -RootModule $rootModuleValue
$moduleManifest = Test-ModuleManifest -Path $testModulePath -ErrorAction Stop
$moduleManifest | Should BeOfType System.Management.Automation.PSModuleInfo
$moduleManifest.RootModule | Should BeNullOrEmpty
$moduleManifest | Should -BeOfType System.Management.Automation.PSModuleInfo
$moduleManifest.RootModule | Should -BeNullOrEmpty
}
It "module manifest containing invalid rootmodule returns error: <rootModuleValue>" -TestCases (
@@ -190,7 +190,7 @@ Describe "Tests for circular references in required modules" -tags "CI" {
try
{
Import-Module $lastModule -ErrorAction Stop
Get-Module $lastModule | Should Not BeNullOrEmpty
Get-Module $lastModule | Should -Not -BeNullOrEmpty
}
finally
{
@@ -234,7 +234,7 @@ Describe "Test-ModuleManifest Performance bug followup" -tags "CI" {
$verbose = $job.ChildJobs[0].Verbose.ReadAll()
# Before the fix, all modules under $pshome will be imported and will be far more than 15 verbose messages. However, we cannot fix the number in case verbose message may vary.
$verbose.Count | Should BeLessThan 15
$verbose.Count | Should -BeLessThan 15
}
AfterAll {