Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test: Add edge case for capturePublicURLFromRequest nil inputs

rcourtmana685ba26b488
diff --git a/internal/api/router_test.go b/internal/api/router_test.go
index 8c2cfb3258..513a1c47a0 100644
--- a/internal/api/router_test.go
+++ b/internal/api/router_test.go
@@ -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)
+ })
+}