test: Add NewNotificationQueue invalid path test for notifications package

This commit is contained in:
rcourtman 2025-12-02 14:17:05 +00:00
parent eb302e6d4e
commit a5f263cf79

View file

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