Files
mesh-catalog/modules/mesh-build-image/cmd/mesh-build-image/asks_say_test.go
T
jschoubben 584fc94baa BG2, BG3: the three build modules check the asker against the seat list and pull the named worker
The runtime source is *steprun.SeatAsks (named worker not bound is said through the module's journal); the callers follow
the seat list (steprun.SeatListCallers).

Builds: design 47 G §543, §544, A-163, A-170

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 05:44:46 +01:00

35 lines
1.3 KiB
Go

package main
import (
"testing"
sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun"
)
// Design 47 G §496, §602 (BG4, BN4, BI4): the module's puller says the seat's events on this node's subjects.
func TestPullerSaysTheSeatsEventsOnItsNodesSubject(t *testing.T) {
var subjects []string
m := &Module{Node: "ace", Capacity: func() int { return 0 },
Callers: func(kind string) ([]string, bool) { return []string{"mesh-pipeline-runner"}, kind == "step" },
SayEvent: func(subject string, _ any, _ string) error { subjects = append(subjects, subject); return nil }}
p := m.Puller(nil, steprun.NewFakeAsks())
if p.Say == nil {
t.Fatal("the puller says no event")
}
if got, ok := p.Callers("step"); !ok || len(got) != 1 {
t.Fatalf("the puller checks the callers of %v, %v, not the module's", got, ok)
}
seat, _ := sdkstep.BuildSeat(sdkstep.AskImage)
for _, event := range []string{"ask-taken", "step-progress", "step-ended"} {
if err := p.Say(event, nil, "id"); err != nil {
t.Fatal(err)
}
}
for i, event := range []string{"ask-taken", "step-progress", "step-ended"} {
if want := "mesh.seat." + seat + ".event." + event + ".ace"; subjects[i] != want {
t.Errorf("%s said on %s, want %s", event, subjects[i], want)
}
}
}