diff options
Diffstat (limited to 'internal/notify/sounds_test.go')
| -rw-r--r-- | internal/notify/sounds_test.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/notify/sounds_test.go b/internal/notify/sounds_test.go index 060bbbe..060b927 100644 --- a/internal/notify/sounds_test.go +++ b/internal/notify/sounds_test.go @@ -14,6 +14,7 @@ package notify import ( "os" "path/filepath" + "syscall" "testing" "github.com/godbus/dbus/v5" @@ -88,6 +89,10 @@ func TestSoundFromHints(t *testing.T) { if err := os.WriteFile(file, []byte("x"), 0o644); err != nil { t.Fatal(err) } + fifo := filepath.Join(t.TempDir(), "pipe") + if err := syscall.Mkfifo(fifo, 0o600); err != nil { + t.Fatal(err) + } v := dbus.MakeVariant cases := []struct { name string @@ -102,6 +107,9 @@ func TestSoundFromHints(t *testing.T) { {"missing file rejected", map[string]dbus.Variant{"sound-file": v(file + ".gone")}, "", false}, {"bad file falls to name", map[string]dbus.Variant{"sound-file": v("x"), "sound-name": v("bell")}, root + "/freedesktop/stereo/bell.oga", false}, {"suppress", map[string]dbus.Variant{"suppress-sound": v(true), "sound-name": v("bell")}, root + "/freedesktop/stereo/bell.oga", true}, + {"fifo rejected", map[string]dbus.Variant{"sound-file": v(fifo)}, "", false}, + {"device rejected", map[string]dbus.Variant{"sound-file": v("/dev/null")}, "", false}, + {"name with a path rejected", map[string]dbus.Variant{"sound-name": v("../freedesktop/stereo/bell")}, "", false}, {"wrong types", map[string]dbus.Variant{"suppress-sound": v("yes"), "sound-name": v(3)}, "", false}, } for _, c := range cases { |
