Files
mesh-sdk/go/seatlist/bootstrap_contracts_test.go
T
jschoubben 8afc3ebdf3
mesh/delivery merged: source.main moved to novox/mesh-sdk@27da949140c6
mesh/check being carried to 8afc3ebdf371 on 93e0a7b50d90 | from 27da949140c6
Revert G's mesh-sdk merge (#189): G merged half, and today's validator refuses G's delivery parts
The group feat/47-G-join11 merged 3 of 17 members on 2026-11-13; G's mesh-sdk alone on main breaks 25 trunk
modules. The operator chose to put the order right: a reader release first, then G whole. This restores main
to 8fbba810 exactly.

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 11:12:48 +01:00

59 lines
2.3 KiB
Go

package seatlist
import (
"bytes"
"os"
"path/filepath"
"slices"
"testing"
"git.novox.be/novox/mesh-sdk/go/internal/beside"
)
// ADR 0635 §3, ADR 0608 §2: a bootstrapped definition is a copy of its seat's file in its contracts module, byte for
// byte, and a seat with a copy has a row here. The contracts are read beside this repository, as a merge check places
// them (mesh-contracts, and mesh-delivery for its `contracts` folder) or, elsewhere, from the copy captured in
// testdata/beside.
func TestEveryBootstrappedDefinitionEqualsItsContractsFile(t *testing.T) {
rows := []struct{ seat, repository, file string }{
{"mesh-broker", "mesh-contracts", "seats/mesh-broker/seat.json"},
{"mesh-config", "mesh-contracts", "seats/mesh-config/seat.json"},
{"node-engine", "mesh-contracts", "seats/node-engine/seat.json"},
{"node-backup", "mesh-contracts", "seats/node-backup/seat.json"},
{"mesh-conditions", "mesh-contracts", "health-and-repair/seats/mesh-conditions/seat.json"},
{"mesh-hand-acts", "mesh-contracts", "health-and-repair/seats/mesh-hand-acts/seat.json"},
{"mesh-watchdogs", "mesh-contracts", "health-and-repair/seats/mesh-watchdogs/seat.json"},
{"operator-channel", "mesh-contracts", "operator-and-conversation/seats/operator-channel/seat.json"},
{"mesh-catalog", "mesh-delivery", "contracts/seats/mesh-catalog/seat.json"},
{"mesh-delivery-checker", "mesh-delivery", "contracts/seats/mesh-delivery-checker/seat.json"},
}
var have []string
for _, d := range Bootstrapped() {
have = append(have, d.Seat)
}
var want []string
for _, r := range rows {
want = append(want, r.seat)
}
slices.Sort(want)
if !slices.Equal(have, want) {
t.Fatalf("the bootstrapped seats are %v, the rows of this test %v: give each bootstrapped seat a row", have, want)
}
for _, r := range rows {
t.Run(r.seat, func(t *testing.T) {
copied, err := bootstrapFiles.ReadFile("bootstrap/" + r.seat + ".json")
if err != nil {
t.Fatal(err)
}
contract, err := os.ReadFile(filepath.Join(beside.Dir(t, r.repository), filepath.FromSlash(r.file)))
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(copied, contract) {
t.Errorf("seatlist/bootstrap/%s.json differs from %s's %s: replace the copy with the contracts' file (ADR 0635 §3)",
r.seat, r.repository, r.file)
}
})
}
}