test: Add edge case for capturePublicURLFromRequest nil inputs

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

View file

@ -780,3 +780,27 @@ func TestCanCapturePublicURL_NilInputs(t *testing.T) {
})
}
}
func TestCapturePublicURLFromRequest_NilInputs(t *testing.T) {
t.Parallel()
t.Run("nil router", func(t *testing.T) {
var r *Router
req := httptest.NewRequest(http.MethodGet, "/", nil)
// Should not panic
r.capturePublicURLFromRequest(req)
})
t.Run("nil request", func(t *testing.T) {
r := &Router{config: &config.Config{}}
// Should not panic
r.capturePublicURLFromRequest(nil)
})
t.Run("nil config", func(t *testing.T) {
r := &Router{config: nil}
req := httptest.NewRequest(http.MethodGet, "/", nil)
// Should not panic
r.capturePublicURLFromRequest(req)
})
}