Files
mesh-sdk/go/seatlist/seatlisttest/seatlisttest.go
T
jschoubben 1aca4991d4 mesh-sdk compiles no seat list and imports no contracts module: catalogue takes its seats from the host, whole seats' names leave it (ADR 0635 §1, §4; issue 1966)
catalogue's working set starts empty and a host gives it the seats it read (UseSeats over SeatsFromDefinitions);
the node-engine's verbs and events take the seat's name from the caller. Tests take their seats from seatlisttest.

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
2026-11-05 12:54:23 +01:00

51 lines
1.7 KiB
Go

// Package seatlisttest is the seat list for tests (novox/hq ADR 0635 §1): mesh-sdk compiles no seat list, so a test that
// judges a manifest, a claim or a composition against the mesh's seats gives them to catalogue from here, as a host gives
// the ones it read from the bus:
//
// catalogue.UseSeats(catalogue.SeatsFromDefinitions(seatlisttest.Definitions()))
//
// The definitions are copies of the contracts modules' files (seats/<seat>.json, parts/<part>.json), resolved with the
// parts they include. A seat's definition is its contracts module's; these are replaced where a seat moves or changes.
// It imports seatdef alone.
package seatlisttest
import (
"embed"
"fmt"
"sort"
"git.novox.be/novox/mesh-sdk/go/seatdef"
)
//go:embed seats/*.json parts/*.json
var files embed.FS
// Definitions are every seat's definition, in seat order. It panics on a file that does not parse.
func Definitions() []seatdef.Definition {
parts := map[string]seatdef.Part{}
pe, _ := files.ReadDir("parts")
for _, e := range pe {
raw, _ := files.ReadFile("parts/" + e.Name())
p, err := seatdef.ParsePart(raw)
if err != nil {
panic(fmt.Sprintf("seatlisttest: parts/%s: %v", e.Name(), err))
}
parts[p.Part] = p
}
var out []seatdef.Definition
se, _ := files.ReadDir("seats")
for _, e := range se {
raw, _ := files.ReadFile("seats/" + e.Name())
d, err := seatdef.Parse(raw)
if err != nil {
panic(fmt.Sprintf("seatlisttest: seats/%s: %v", e.Name(), err))
}
if d, err = seatdef.Resolve(d, parts); err != nil {
panic(fmt.Sprintf("seatlisttest: seats/%s: %v", e.Name(), err))
}
out = append(out, d)
}
sort.Slice(out, func(i, j int) bool { return out[i].Seat < out[j].Seat })
return out
}