Files
mesh-delivery/modules/mesh-delivery-checker/internal/check/buildseats_test.go
T
jschoubben bd20ba5b8f Checker: the build modules are the holders of the build seats on the seat list, never a name
The checker's fixed names of the build modules (buildmodules.go in its program, rules and check) go: the
Examiner finds each build module by the language its seat's acting rule builds (buildrun.BuildSeats over
the seat list's definitions and the holders the indexer's modules name by their manifests' claims), the facts
carry the language where a level counts by it, and the program's manifest reads the steps and toolchains of
the seats and hears their toolchain-reported. The tools read the steps of each holder and follow the seat
list as the view does. Timers stay (A-118).

Builds: design 47 G A-82, A-118, §204
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 01:31:24 +01:00

59 lines
3.1 KiB
Go

package check
import (
"testing"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun"
"git.novox.be/novox/mesh-sdk/go/seatdef"
)
// The holders of the build seats in the tests' seat list: names the checker's code does not know, found by the seats'
// acting rules (design 47 G A-82).
const (
goBuildModule = "mesh-build-go"
nodeBuildModule = "mesh-build-node"
)
// testSeats is the finder over the build seats of the tests' seat list.
func testSeats() *buildrun.BuildSeats {
rule := func(on string) seatdef.Definition {
return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}}
}
defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript")}
holders := map[string]string{"node-build-go": goBuildModule, "node-build-node": nodeBuildModule}
return buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok })
}
// stepStatesOf is a Reader's StepStates over fixed states.
func stepStatesOf(m map[string]StateRead) func() map[string]StateRead {
return func() map[string]StateRead { return m }
}
// The checker names no build module (design 47 G A-82): it finds each by the language its seat's acting rule builds, whatever the
// holder is called, and says that holder's name in what it judges.
func TestTheBuildModulesAreFoundOnTheSeatListWhateverTheyAreCalled(t *testing.T) {
rule := func(on string) seatdef.Definition {
return seatdef.Definition{Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: on}}}
}
defs := map[string]seatdef.Definition{"node-build-go": rule("go"), "node-build-node": rule("typescript"), "node-build-image": rule("kind:image")}
holders := map[string]string{"node-build-go": "compilers", "node-build-node": "bundlers"}
j := &Examiner{Seats: buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, func(seat string) (string, bool) { h, ok := holders[seat]; return h, ok })}
if got := j.goModule(); got != "compilers" {
t.Errorf("the module that judges Go = %q, want its seat's holder", got)
}
if got, lang, ask := j.buildModuleOf(languageTypeScript), j.languageOf("bundlers"), j.askLanguageOf("bundlers"); got != "bundlers" || lang != languageTypeScript || ask != "node" {
t.Errorf("TypeScript: module %q, language %q, ask language %q", got, lang, ask)
}
if got := j.languageOf("mesh-build-go"); got != "" {
t.Errorf("a module that holds no build seat builds with %q", got)
}
if !changesBuildGo(catalogueRepository, "compilers", []string{"modules/compilers/main.go"}) || changesBuildGo(catalogueRepository, "compilers", []string{"modules/mesh-build-go/main.go"}) {
t.Error("a change under the Go build module's own directory is the one that changes it")
}
// With no seat on the list the failure still names where it is: the seat.
none := &Examiner{Seats: buildrun.NewBuildSeats(func() map[string]seatdef.Definition { return defs }, nil)}
if got := none.goModule(); got != "node-build-go" {
t.Errorf("a build seat no module holds is named by the seat, got %q", got)
}
}