deadUpstreamAddr returns a TCP address that is guaranteed to refuse connections: we bind a listener, note its address, close it immediately, and return the address. Any dial to that address will get ECONNREFUSED.
(t *testing.T)
| 64 | // connections: we bind a listener, note its address, close it immediately, |
| 65 | // and return the address. Any dial to that address will get ECONNREFUSED. |
| 66 | func deadUpstreamAddr(t *testing.T) string { |
| 67 | t.Helper() |
| 68 | ln, err := net.Listen("tcp", "127.0.0.1:0") |
| 69 | if err != nil { |
| 70 | t.Fatalf("failed to create dead upstream listener: %v", err) |
| 71 | } |
| 72 | addr := ln.Addr().String() |
| 73 | ln.Close() |
| 74 | return addr |
| 75 | } |
| 76 | |
| 77 | // testTransport wraps http.Transport to: |
| 78 | // 1. Set the URL scheme to "http" when it is empty (matching what |
no test coverage detected