test: Add edge case for canCapturePublicURL nil inputs

Tests the early return paths when config or request are nil.
This commit is contained in:
rcourtman 2025-12-01 23:56:59 +00:00
parent f0688db9af
commit b9f9077496

View file

@ -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)
}
})
}
}