Don't write DNS resolution errors on Test-Connection -Quiet (#12204)

This commit is contained in:
Joel Sallow (/u/ta11ow) authored and GitHub committed 2020-03-28 15:50:32 +05:00
1 parent 1ec7c826f0
commit dfe9955346
2 files changed
+66 -20

No files matched your search

@@ -59,18 +59,19 @@ Describe "Test-Connection" -tags "CI" {
$result2 | Should -BeFalse
}
It "Ping fake host" {
It 'returns false without errors for an unresolvable address when using -Quiet' {
Test-Connection -Quiet -ErrorAction Stop -Count 1 -TargetName "fakeHost" | Should -BeFalse
}
{ $result = Test-Connection "fakeHost" -Count 1 -Quiet -ErrorAction Stop } |
It "Ping fake host" {
{ Test-Connection "fakeHost" -Count 1 -ErrorAction Stop } |
Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand"
# Error code = 11001 - Host not found.
if ((Get-PlatformInfo).Platform -match "raspbian") {
$code = 11
}
elseif (!$IsWindows) {
} elseif (!$IsWindows) {
$code = -131073
}
else {
} else {
$code = 11001
}
$error[0].Exception.InnerException.ErrorCode | Should -Be $code