From b9f9077496462a6c4c095683f13d7ea174f22797 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 1 Dec 2025 23:56:59 +0000 Subject: [PATCH] test: Add edge case for canCapturePublicURL nil inputs Tests the early return paths when config or request are nil. --- internal/api/router_test.go | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/internal/api/router_test.go b/internal/api/router_test.go index 1f19260..8c2cfb3 100644 --- a/internal/api/router_test.go +++ b/internal/api/router_test.go @@ -4,6 +4,8 @@ import ( "net/http" "net/http/httptest" "testing" + + "github.com/rcourtman/pulse-go-rewrite/internal/config" ) func TestIsDirectLoopbackRequest(t *testing.T) { @@ -736,3 +738,45 @@ func TestShouldAppendForwardedPort(t *testing.T) { }) } } + +func TestCanCapturePublicURL_NilInputs(t *testing.T) { + t.Parallel() + + req := httptest.NewRequest(http.MethodGet, "/", nil) + cfg := &config.Config{} + + tests := []struct { + name string + cfg *config.Config + req *http.Request + want bool + }{ + { + name: "nil config", + cfg: nil, + req: req, + want: false, + }, + { + name: "nil request", + cfg: cfg, + req: nil, + want: false, + }, + { + name: "both nil", + cfg: nil, + req: nil, + want: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := canCapturePublicURL(tt.cfg, tt.req) + if got != tt.want { + t.Errorf("canCapturePublicURL() = %v, want %v", got, tt.want) + } + }) + } +}