mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-11 22:12:23 +00:00
test: Add NewNotificationQueue invalid path test for notifications package
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user