test: Add NewNotificationQueue invalid path test for notifications package
This commit is contained in:
parent
eb302e6d4e
commit
a5f263cf79
1 changed files with 19 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ package notifications
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -844,3 +845,21 @@ func TestPerformCleanup(t *testing.T) {
|
||||||
nq.performCleanup()
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue