8000 Use new Pester syntax: -Parameter for Pester tests in Microsoft.PowerShell.Management module. by kalgiz · Pull Request #6294 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Use new Pester syntax: -Parameter for Pester tests in Microsoft.PowerShell.Management module. #6294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6e0b7dc
Clean up tests in Microsoft.PowerShell.Management to use -Parameter s…
kalgiz Mar 2, 2018
6fb3282
[Feature] Merge branch 'master' of https://github.com/kalgiz/PowerShe…
kalgiz Mar 2, 2018
a453e49
Add line deleted by mistake.
kalgiz Mar 2, 2018
2645036
[Feature] Resolve conflict
kalgiz Mar 3, 2018
f7e6998
Merge branch 'master' of https://github.com/kalgiz/PowerShell into ne…
kalgiz Mar 6, 2018
8661ef7
Tests syntax correction for module Microsoft.PowerShell.Management
kalgiz Mar 6, 2018
ec1292f
Tests syntax correction for module Microsoft.PowerShell.Management
kalgiz Mar 6, 2018
170da9f
Test correction
kalgiz Mar 6, 2018
b591202
[Feature] Tests correction in module Microsoft.PowerShell.Management.
kalgiz Mar 6, 2018
3113dcb
[Feature] Clear-Content test correction.
kalgiz Mar 7, 2018
57a2688
[Feature] Test correction.
kalgiz Mar 7, 2018
f4955aa
Merge branch 'master' of https://github.com/kalgiz/PowerShell into ne…
kalgiz Mar 7, 2018
030ffa0
[Feature] Microsoft.PowerShell.Management module tests.
kalgiz Mar 7, 2018
5a0c067
[Feature] Remove-EventLog test correction.
kalgiz Mar 7, 2018
9c93d1a
[Feature] Use Should -Throw -ErrorId instead of try-catch in module M…
kalgiz Mar 7, 2018
ddff370
Merge branch 'master' of https://github.com/kalgiz/PowerShell into ne…
kalgiz Mar 8, 2018
7531e93
[Feature] Tests correction in Microsoft.PowerShell.Managemet module.
kalgiz Mar 8, 2018
67ff3ef
[Feature] Merge branch 'master' of https://github.com/kalgiz/PowerShe…
kalgiz Mar 8, 2018
f0cc737
[Feature] Tests correction in Microsoft.PowerShell.Managemet module.
kalgiz Mar 8, 2018
ea48f96
Merge branch 'master' of https://github.com/kalgiz/PowerShell into ne…
kalgiz Mar 9, 2018
fda9da7
[Feature] Tests correction
kalgiz Mar 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Feature] Tests correction in Microsoft.PowerShell.Managemet module.
  • Loading branch information
kalgiz committed Mar 8, 2018
commit 7531e93eb73f5030433155cd9e8dbfc94e03fe9f
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe "Basic Alias Provider Tests" -Tags "CI" {

It "Test executing the new alias" {
$result = Invoke-Expression $testAliasName
$result | Should -BeOfType DateTime
$result | Should -BeOfType [DateTime]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Describe "Clear-Content cmdlet tests" -Tags "CI" {
It "the '-Stream' dynamic parameter is visible to get-command in the filesystem" -Skip:(!$IsWindows) {
try {
push-location TESTDRIVE:
(get-command clear-content -stream foo).parameters.keys -eq "stream" | should be "stream"`
(get-command clear-content -stream foo).parameters.keys -eq "stream" | Should -Be "stream"
}
finally {
pop-location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ Describe "Control Service cmdlet tests" -Tags "Feature","RequireAdminOnWindows"
$wasStopped = $true
$spooler = Start-Service Spooler -PassThru
}
$spooler.Status | Should -Be "Running"
$spooler.Status | Should -BeExactly "Running"
$spooler = Stop-Service Spooler -PassThru
$spooler.Status | Should -Be "Stopped"
(Get-Service Spooler).Status | Should -Be "Stopped"
$spooler.Status | Should -BeExaclty "Stopped"
(Get-Service Spooler).Status | Should -BeExactly "Stopped"
$spooler = Start-Service Spooler -PassThru
$spooler.Status | Should -Be "Running"
(Get-Service Spooler).Status | Should -Be "Running"
$spooler.Status | Should -BeExactly "Running"
(Get-Service Spooler).Status | Should -BeExactly "Running"
Stop-Service Spooler
(Get-Service Spooler).Status | Should -Be "Stopped"
(Get-Service Spooler).Status | Should -BeExactly "Stopped"
$spooler = Restart-Service Spooler -PassThru
$spooler.Status | Should -Be "Running"
(Get-Service Spooler).Status | Should -Be "Running"
$spooler.Status | Should -BeExactly "Running"
(Get-Service Spooler).Status | Should -BeExactly "Running"
} finally {
if ($wasStopped) {
Stop-Service Spooler
Expand All @@ -72,9 +72,9 @@ Describe "Control Service cmdlet tests" -Tags "Feature","RequireAdminOnWindows"
}
$service | Should -Not -BeNullOrEmpty
Suspend-Service $serviceName
(Get-Service $serviceName).Status | Should -Be "Paused"
(Get-Service $serviceName).Status | Should -BeExactly "Paused"
Resume-Service $serviceName
(Get-Service $serviceName).Status | Should -Be "Running"
(Get-Service $serviceName).Status | Should -BeExactly "Running"
} finally {
Set-Service $serviceName -Status $originalState
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Describe "Validate Copy-Item Remotely" -Tags "CI" {
{
$copiedFilePath = ([string]$file).Replace("SourceDirectory", "DestinationDirectory\SourceDirectory")
$copiedFilePath | Should -Exist

(Get-Item $copiedFilePath).Length | Should -Be (Get-Item $file).Length
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows"
$filenamePattern = "AlphaFile[12]\.txt"
New-Item -ItemType SymbolicLink -Path $alphaLink -Value $alphaDir
$ci = Get-ChildItem $alphaLink
$ci.Count | Should -BeExactly 3
$ci.Count | Should -Be 3
$ci[1].Name | Should -MatchExactly $filenamePattern
$ci[2].Name | Should -MatchExactly $filenamePattern
}
Expand Down
F7FC
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ try {
$expectedProperties = @("BiosBIOSVersion")
$propertyFilter = "BiosBIOSVersion"
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be 1
$computerInfoWithProp.$propertyFilter | Should -Be $expected.$propertyFilter
}
Expand All @@ -1076,7 +1076,7 @@ try {
$expectedProperties = @("BiosBIOSVersion","BiosBuildNumber","BiosCaption")
$propertyFilter = @("BiosBIOSVersion","BiosBuildNumber","BiosCaption")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be 3
foreach($property in $propertyFilter) {
$ComputerInfoWithProp.$property | Should -Be $Expected.$property
Expand All @@ -1091,7 +1091,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionXXX")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}

Expand All @@ -1103,7 +1103,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionXXX","InvalidProperty1","InvalidProperty2","InvalidProperty3")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}

Expand All @@ -1115,7 +1115,7 @@ try {
$expectedProperties = @("BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$propertyFilter = @("InvalidProperty1","BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$realProperties = $propertyFilter | Where-Object { $_ -notmatch "^InvalidProperty[0-9]+" }
@($computerInfoWithProp.psobject.properties).count | Should -Be $realProperties.Count
foreach ( $property in $realProperties )
Expand All @@ -1132,7 +1132,7 @@ try {
$expectedProperties = @("BiosCodeSet","BiosCurrentLanguage","BiosDescription")
$propertyFilter = @("BiosCodeSet","InvalidProperty1","BiosCurrentLanguage","BiosDescription","InvalidProperty2")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
$realProperties = $propertyFilter | Where-Object { $_ -notmatch "^InvalidProperty[0-9]+" }
@($computerInfoWithProp.psobject.properties).count | Should -Be $realProperties.Count
foreach ( $property in $realProperties )
Expand All @@ -1149,7 +1149,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage")
$propertyFilter = @("BiosC*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
Expand All @@ -1165,7 +1165,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage","CsCaption")
$propertyFilter = @("BiosC*","CsCaption")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
Expand All @@ -1181,7 +1181,7 @@ try {
$expectedProperties = @("BiosCaption","BiosCharacteristics","BiosCodeSet","BiosCurrentLanguage","CsCaption")
$propertyFilter = @("CsCaption","InvalidProperty1","BiosC*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be $expectedProperties.Count
foreach ( $property in $expectedProperties )
{
Expand All @@ -1197,7 +1197,7 @@ try {
$expectedProperties = $null
$propertyFilter = @("BiosBIOSVersionX*")
$computerInfoWithProp = Get-ComputerInfoForTest -properties $propertyFilter
$computerInfoWithProp | Should -Beoftype [pscustomobject]
$computerInfoWithProp | Should -BeOfType [pscustomobject]
@($computerInfoWithProp.psobject.properties).count | Should -Be 0
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ baz
$expected = 'foo'

$actual = Get-Content -Path $testPath -Tail $tailCount -Encoding $encodingName
$actual | Should -BeOfType "[string]"
$actual | Should -BeOfType [string]
$actual.Length | Should -Be $tailCount
$actual[0] | Should -BeExactly $expected
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ Describe "New-Item with links" -Tags @('CI', 'RequireAdminOnWindows') {

It "Should error correctly when failing to create a symbolic link" -Skip:($IsWindows -or $IsElevated) {
# This test expects that /sbin exists but is not writable by the user
{ New-Item -ItemType SymbolicLink -Path "/sbin/powershell-test" -Target $FullyQualifiedFolder -ErrorAction Stop } | Should -Throw -ErrorId "NewItemSymbolicLinkElevationRequired,Microsoft.PowerShell.Commands.NewItemCommand"
{ New-Item -ItemType SymbolicLink -Path "/sbin/powershell-test" -Target $FullyQualifiedFolder -ErrorAction Stop } |
Should -Throw -ErrorId "NewItemSymbolicLinkElevationRequired,Microsoft.PowerShell.Commands.NewItemCommand"
}

It "New-Item -ItemType SymbolicLink should understand directory path ending with slash" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {
}
#CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented
It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($True) {
{Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw
{ Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ErrorAction Stop } | Should -Not -Throw
{ Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventID 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"
{ Get-EventLog -LogName TestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ Describe "Split-Path" -Tags "CI" {
}

It 'Does not split a drive leter'{
Split-Path -Path 'C:\' | Should -Be ''
Split-Path -Path 'C:\' | Should -BeNullOrEmpty
}
}
0