High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
test: hold the bare-banner health probe to its timeout ceiling
Luigi Agostiba037bc6696c
diff --git a/cmd/pinchtab/root_test.go b/cmd/pinchtab/root_test.goindex 4c7734c0..8e441344 100644--- a/cmd/pinchtab/root_test.go+++ b/cmd/pinchtab/root_test.go@@ -7,6 +7,7 @@ import ("net/http/httptest""strings""testing"+ "time")func TestFetchHealthSnapshotClassifiesOnlyValidDashboardHealthAsRunning(t *testing.T) {@@ -199,6 +200,50 @@ func TestFetchHealthSnapshotDoesNotSendBearerToken(t *testing.T) {}}+func TestPrintAgentHintsStaysBoundedAgainstASilentListener(t *testing.T) {+ listener, err := net.Listen("tcp", "localhost:0")+ if err != nil {+ t.Fatalf("Listen() error = %v", err)+ }+ defer func() { _ = listener.Close() }()++ held := make(chan struct{})+ defer close(held)+ go func() {+ for {+ conn, acceptErr := listener.Accept()+ if acceptErr != nil {+ return+ }+ go func() {+ <-held+ _ = conn.Close()+ }()+ }+ }()++ _, port, err := net.SplitHostPort(listener.Addr().String())+ if err != nil {+ t.Fatalf("SplitHostPort() error = %v", err)+ }+ cfg := testRuntimeConfig()+ cfg.Port = port++ const ceiling = 10 * time.Second+ start := time.Now()+ output := captureStdout(t, func() {+ printAgentHints(cfg)+ })+ elapsed := time.Since(start)++ if elapsed >= ceiling {+ t.Fatalf("bare banner spent %v on a port that accepts the connection and never answers; the probe must stay bounded or `pinchtab` hangs on a firewalled port, which is the whole reason the banner used to refuse to probe", elapsed)+ }+ if !strings.Contains(output, string(healthSnapshotStopped)) {+ t.Fatalf("expected %q after the probe gave up, got\n%s", healthSnapshotStopped, output)+ }+}+func newLocalhostHealthServer(t *testing.T, status int, body string) *httptest.Server {t.Helper()