Files
mesh-delivery/modules/mesh-grants/internal/grants/defined_test.go
T
jschoubben 8b41346466 GR4 (§386, §644): the grants part tells catalogue.Hearing which events are defined
A seat definition's events of the seat list, and mesh-sdk's four finding events (views.FindingSubjects), so a `*` emitter before one reaches each declaring module's own stream; any other `*` entry stays the shared stream's.

Builds: design 47 G §386, §474, §644

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 21:46:19 +01:00

28 lines
1.3 KiB
Go

package grants
import (
"slices"
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
// Design 47 G §386, §474, §644: a `*` emitter before one of mesh-sdk's finding events reaches each declaring module's own
// stream, with no seat list read; one before an event no definition names stays the shared stream's.
func TestAStarEmitterBeforeAFindingEventReachesEachDeclaringStream(t *testing.T) {
shelf := map[string]catalogue.Manifest{
"a": {Module: "a", Streams: []catalogue.StreamDeclaration{{Name: "a-findings", Events: []string{"finding-written"}}}},
"b": {Module: "b", Streams: []catalogue.StreamDeclaration{{Name: "b-usage", Events: []string{"usage"}}}},
}
none := func(string, string) []any { return nil }
defined := func(e string) bool { return definedEventsOf(nil)[e] }
keeper := catalogue.Manifest{Module: "keeper", Consumes: []string{"*.finding-written", "*.usage"}}
hears, touches, onEvents := hearsOf(keeper, shelf, "ace", none, keeper.Consumes, defined)
if !touches || len(hears) != 1 || hears[0].Emitter != "a" || !slices.Equal(onEvents, []string{"*.finding-written", "*.usage"}) {
t.Fatalf("heard %+v (touches %v, on EVENTS %v)", hears, touches, onEvents)
}
if hears, _, _ := hearsOf(keeper, shelf, "ace", none, keeper.Consumes, nil); len(hears) != 0 {
t.Fatalf("with no event defined, heard %+v", hears)
}
}