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 NewNotificationQueue invalid path test for notifications package

rcourtman89b624c7315d
diff --git a/internal/notifications/queue_test.go b/internal/notifications/queue_test.go
index c537b28846..d54aba7e2f 100644
--- a/internal/notifications/queue_test.go
+++ b/internal/notifications/queue_test.go
@@ -2,6 +2,7 @@ package notifications
import (
"fmt"
+ "os"
"testing"
"time"
@@ -844,3 +845,21 @@ func TestPerformCleanup(t *testing.T) {
nq.performCleanup()
})
}
+
+func TestNewNotificationQueue_InvalidPath(t *testing.T) {
+ // Test with a path that cannot be created (file exists where directory expected)
+ tempDir := t.TempDir()
+
+ // Create a file at the path where we'd want to create a directory
+ blockingFile := tempDir + "/blocked"
+ if err := os.WriteFile(blockingFile, []byte("blocking"), 0644); err != nil {
+ t.Fatalf("failed to create blocking file: %v", err)
+ }
+
+ // Try to create queue at a path nested under the blocking file
+ invalidPath := blockingFile + "/subdir"
+ _, err := NewNotificationQueue(invalidPath)
+ if err == nil {
+ t.Error("expected error when creating notification queue with invalid path, got nil")
+ }
+}