Bound notification delivery and expansion

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 14:38:02 -04:00
committed by Brandon McGinty
parent 4497d41077
commit d64e5125dd
4 changed files with 43 additions and 12 deletions
+19
View File
@@ -4,6 +4,7 @@ import (
"io"
"strings"
"testing"
"time"
"git.stormux.org/storm/barnard/gumble/gumble"
)
@@ -34,6 +35,24 @@ func TestReadFIFOStopsOnEOF(t *testing.T) {
}
}
// Regression: sequential substitutions re-expanded placeholders embedded in
// server-provided fields, and a slow notifier blocked callback goroutines.
func TestNotificationExpansionIsSinglePassAndNotifyDoesNotBlock(t *testing.T) {
got := expandNotification("%event %what", []string{"event", "who", "%event"})
if got != "event %event" {
t.Fatalf("unexpected expansion %q", got)
}
b := &Barnard{notifyChannel: make(chan []string, 1)}
b.Notify("one", "", "")
done := make(chan struct{})
go func() { b.Notify("two", "", ""); close(done) }()
select {
case <-done:
case <-time.After(time.Second):
t.Fatal("Notify blocked on a full queue")
}
}
func TestUserChangeNotification(t *testing.T) {
current := &gumble.Channel{ID: 1, Name: "Current"}
other := &gumble.Channel{ID: 2, Name: "Other"}