Fix common Windows failure (#10397)

The `getNonLoopBackIP` may grab an IP from an interface that
doesn't allow binding (on Windows), so this test consistently fails.

We exclude that specific error.
master
Klaus Post 4 years ago committed by GitHub
parent 1c085f7d1a
commit a89d6b8e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      cmd/http/listener_test.go

@ -186,6 +186,10 @@ func TestHTTPListenerStartClose(t *testing.T) {
testCase.serverAddrs, testCase.serverAddrs,
) )
if err != nil { if err != nil {
if strings.Contains(err.Error(), "The requested address is not valid in its context") {
// Ignore if IP is unbindable.
continue
}
t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err) t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err)
} }
@ -225,6 +229,10 @@ func TestHTTPListenerAddr(t *testing.T) {
testCase.serverAddrs, testCase.serverAddrs,
) )
if err != nil { if err != nil {
if strings.Contains(err.Error(), "The requested address is not valid in its context") {
// Ignore if IP is unbindable.
continue
}
t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err) t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err)
} }
@ -261,6 +269,10 @@ func TestHTTPListenerAddrs(t *testing.T) {
testCase.serverAddrs, testCase.serverAddrs,
) )
if err != nil { if err != nil {
if strings.Contains(err.Error(), "The requested address is not valid in its context") {
// Ignore if IP is unbindable.
continue
}
t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err) t.Fatalf("Test %d: error: expected = <nil>, got = %v", i+1, err)
} }

Loading…
Cancel
Save