Files
marqdo/plugins/web/internal/ws/hub_test.go
T
cflmyandCursor 4c06851e0e feat(web): Go W-G8 WebSocket routes and access_log
Register route_ws/ws_connect ABIs with an in-process broadcast hub
so offline WS broadcast and access_log smokes pass on libweb.so.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-10 19:31:03 +08:00

31 lines
487 B
Go

package ws
import (
"testing"
"time"
)
func TestBroadcastFanout(t *testing.T) {
path := "/t-fanout-go"
ch := subscribe(path)
ch2 := subscribe(path)
Publish(path, "hi")
if got := readOne(ch); got != "hi" {
t.Fatalf("ch1=%q", got)
}
if got := readOne(ch2); got != "hi" {
t.Fatalf("ch2=%q", got)
}
unsubscribe(path, ch)
unsubscribe(path, ch2)
}
func readOne(ch chan string) string {
select {
case s := <-ch:
return s
case <-time.After(time.Second):
return ""
}
}