A * emitter before a finding event reaches the stream a part asked for by the template events (its finding-events) beside the old stream; a part's finding stream is published on its own node's subjects alone. Builds: design 47 G §386, §529, §515 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
35 lines
1.7 KiB
Go
35 lines
1.7 KiB
Go
package grants
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// A `*` emitter before a finding event reaches both forms of a part's finding stream (design 47 G §386, §529): the old stream a
|
|
// foundation part declares and the template stream another part asks for as `finding-events`.
|
|
func TestTheKeepersConsumerOnEitherFindingForm(t *testing.T) {
|
|
events := []string{"finding-written", "finding-cleared", "findings-stated"}
|
|
declared := map[string]catalogue.Manifest{
|
|
"old-part": {Module: "old-part", Streams: []catalogue.StreamDeclaration{{Name: "old-part-findings", Events: events}}},
|
|
"new-part": {Module: "new-part", BusState: []catalogue.BusStateEntry{
|
|
{Name: "findings", Storage: catalogue.StorageKeyValue, Template: catalogue.TemplateState},
|
|
{Name: "finding-events", Storage: catalogue.StorageStream, Template: catalogue.TemplateEvents, Events: events}}},
|
|
"quiet": {Module: "quiet", BusState: []catalogue.BusStateEntry{{Name: "other", Storage: catalogue.StorageStream, Template: catalogue.TemplateEvents,
|
|
Events: []string{"tick.*"}}}},
|
|
}
|
|
keeper := catalogue.Manifest{Module: "keeper", Consumes: []string{"*.finding-written"}}
|
|
heard, touches, _ := hearsOf(keeper, declared, "one", nil, keeper.Consumes, func(e string) bool { return e == "finding-written" })
|
|
got := map[string][]string{}
|
|
for _, h := range heard {
|
|
got[h.Emitter] = h.Filters
|
|
}
|
|
if !touches || len(got) != 2 || !slices.Equal(got["new-part"], []string{"mesh.bus.new-part.finding-events.finding-written.*"}) || len(got["old-part"]) != 1 {
|
|
t.Errorf("heard %+v", got)
|
|
}
|
|
if heard[len(heard)-1].Stream != "new-part_finding-events" {
|
|
t.Errorf("the template stream's bus name: %+v", heard)
|
|
}
|
|
}
|