Files
mesh-sdk/go/process/event_hub_test.go
T
jschoubben 8afc3ebdf3
mesh/delivery merged: source.main moved to novox/mesh-sdk@27da949140c6
mesh/check being carried to 8afc3ebdf371 on 93e0a7b50d90 | from 27da949140c6
Revert G's mesh-sdk merge (#189): G merged half, and today's validator refuses G's delivery parts
The group feat/47-G-join11 merged 3 of 17 members on 2026-11-13; G's mesh-sdk alone on main breaks 25 trunk
modules. The operator chose to put the order right: a reader release first, then G whole. This restores main
to 8fbba810 exactly.

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 11:12:48 +01:00

39 lines
1.1 KiB
Go

package process
import (
"testing"
"github.com/nats-io/nats.go/jetstream"
)
func TestTheHubMatchesSubjectsAndRefusesOverlappingPatterns(t *testing.T) {
for _, c := range []struct {
a, b string
match, overlap bool
}{
{"mesh.mod.*.event.views.*", "mesh.mod.o.event.views.x", true, true},
{"mesh.mod.p.event.>", "mesh.mod.p.event", false, false},
{"mesh.mod.p.event.a", "mesh.mod.q.event.a", false, false},
{"mesh.mod.p.event.>", "mesh.mod.*.event.a", false, true},
{"mesh.mod.p.event.a", "mesh.mod.p.event.a.b", false, false},
} {
if got := subjectMatches(c.a, c.b); got != c.match && c.match {
t.Errorf("%s should match %s", c.a, c.b)
}
if got := subjectsOverlap(c.a, c.b); got != c.overlap {
t.Errorf("overlap(%s, %s) = %v", c.a, c.b, got)
}
}
h := NewEventHub(nil)
nop := func(jetstream.Msg) {}
if err := h.Handle("mesh.mod.p.event.>", nop); err != nil {
t.Fatal(err)
}
if err := h.Handle("mesh.mod.*.event.a", nop); err == nil {
t.Fatal("an overlapping pattern was accepted")
}
if err := h.Handle("mesh.mod.q.event.>", nop); err != nil {
t.Fatal(err)
}
}