Join: mesh-config's whole test reads the subject the runtime publishes on from the manifest
The seat definition names mesh-config's renamed, retiring and retired on its own stream (mesh.stream, A1c), and the runtime publishes an event the module's stream carries there; the test assumed EVENTS (mesh.mod) for every event and failed at the joined heads. Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -32,8 +33,10 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshconfig"
|
||||
oc "git.novox.be/novox/mesh-contracts/go/seats/operatorchannel"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
"git.novox.be/novox/mesh-sdk/go/health"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
"git.novox.be/novox/mesh-sdk/go/testbus"
|
||||
)
|
||||
|
||||
@@ -452,7 +455,13 @@ func (p *player) conforms(key string, into any, subject func(holder string) stri
|
||||
if err := dec.Decode(into); err != nil {
|
||||
p.t.Errorf("the published %s %s does not match the seat's definition: %v", key, s.Body, err)
|
||||
}
|
||||
if got, want := "mesh.mod."+Module+".event."+s.Key, subject(Module); got != want {
|
||||
// The runtime publishes an event its manifest's own stream carries on that stream (mesh.stream), any other on
|
||||
// EVENTS (mesh.mod).
|
||||
got := "mesh.mod." + Module + ".event." + s.Key
|
||||
if streamCarries(p.t, s.Key) {
|
||||
got = process.ModuleStreamSubject(Module, s.Key)
|
||||
}
|
||||
if want := subject(Module); got != want {
|
||||
p.t.Errorf("%s is published on %s, the definition names %s", key, got, want)
|
||||
}
|
||||
}
|
||||
@@ -788,3 +797,22 @@ func TestConfigWholeRenamesAndRetiresAgainstTheBus(t *testing.T) {
|
||||
p2.conforms(EventRetired, &meshconfig.RetiredHolderEvent{}, meshconfig.HolderSubjectRetired)
|
||||
eventually(t, "the retirement is dropped", func() bool { _, ok := p2.get(RetiringState, "radio.band"); return !ok })
|
||||
}
|
||||
|
||||
// streamCarries says whether the module's manifest names event among its own streams' events.
|
||||
func streamCarries(t *testing.T, event string) bool {
|
||||
t.Helper()
|
||||
raw, err := os.ReadFile(filepath.Join("..", "..", "module.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m, err := catalogue.Decode(raw)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, st := range m.Streams {
|
||||
if slices.Contains(st.Events, event) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user