Fix tests to not write errors to console (#13010)

This commit is contained in:
Paul Higinbotham
2020-06-23 14:07:52 -07:00
committed by GitHub
parent 0d75cfdc2d
commit 7b4e80f07d
2 changed files with 8 additions and 8 deletions
@@ -24,14 +24,14 @@ Describe "Get-FileHash" -Tags "CI" {
}
It "Should write non-terminating error if argument is a folder" {
$result = $PSHOME, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
$result = $PSHOME, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable -ErrorAction SilentlyContinue
$result.Count | Should -Be 1
$errorVariable.FullyQualifiedErrorId | Should -BeExactly "UnauthorizedAccessError,Microsoft.PowerShell.Commands.GetFileHashCommand"
}
It "Should write non-terminating error if a file is locked" -Skip:(-not $IsWindows) {
$pagefilePath = (Get-CimInstance -ClassName Win32_PageFileusage).Name
$result = $pagefilePath, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable
$result = $pagefilePath, "${pshome}\pwsh.dll" | Get-FileHash -ErrorVariable errorVariable -ErrorAction SilentlyContinue
$result.Count | Should -Be 1
$errorVariable.FullyQualifiedErrorId | Should -BeExactly "FileReadError,Microsoft.PowerShell.Commands.GetFileHashCommand"
}
@@ -89,7 +89,7 @@ Describe "Get-FileHash" -Tags "CI" {
$newPath = Get-FileHash -Path $testDocumentCopy | Rename-Item -NewName {$_.Hash} -PassThru
$newPath.FullName | Should -Exist
Remove-Item -Path $testDocumentCopy -Force
Remove-Item -Path $testDocumentCopy -Force -ErrorAction SilentlyContinue
}
}
}
@@ -4,10 +4,10 @@ Describe "Get-RunspaceDebug" -Tags "CI" {
Context "Check return types of RunspaceDebug" {
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
$rs = Get-RunspaceDebug
$rs | Should -Not -BeNullOrEmpty
$rs[0] | Should -BeOfType Microsoft.PowerShell.Commands.PSRunspaceDebug
}
It "Should return Microsoft.Powershell.Commands.PSRunspaceDebug as the return type" {
$rs = Get-RunspaceDebug -ErrorAction SilentlyContinue
$rs | Should -Not -BeNullOrEmpty
$rs[0] | Should -BeOfType Microsoft.PowerShell.Commands.PSRunspaceDebug
}
}
}