Point the unreachable-app test at port 1 (closes #51)
check / check (push) Successful in 2m6s

TestAnswers502WhenTheAppCannotBeReached closed a listener and pointed
smallwebwaf at its port, which another test running in parallel could
open in between, so the test sometimes got that server's answer instead
of a 502. It now uses 127.0.0.1:1: nothing listens there, and a test
listening on port 0 is always given a port from 32768 up, so no test
can take it. No other test reuses a closed listener's port.

Model: opus-5-5
This commit is contained in:
2026-10-04 04:13:50 +00:00
parent 6bd5f620f6
commit d8b8936f46
+2 -10
View File
@@ -5,7 +5,6 @@ import (
"bytes"
"errors"
"io"
"net"
"net/http"
"slices"
"strings"
@@ -354,15 +353,8 @@ func TestRefusesHeadersOver32KiB(t *testing.T) {
func TestAnswers502WhenTheAppCannotBeReached(t *testing.T) {
t.Parallel()
listener, err := (&net.ListenConfig{}).Listen(t.Context(), "tcp", localhost+":0")
if err != nil {
t.Fatalf("listen: %v", err)
}
closedAddr := listener.Addr().String()
_ = listener.Close()
addr, out := startProxy(t, "http://"+closedAddr, nil)
// No test can listen on port 1: listening on port 0 gets one from 32768 up.
addr, out := startProxy(t, "http://"+localhost+":1", nil)
wantStatus(t, get(t, addr, "/"), http.StatusBadGateway)
wantLine(t, out.requestLine(t), http.StatusBadGateway,