Files
mesh-sdk/go/seatlist/bootstrap_contracts_test.go
T
jschoubben 5fa64be894 Revert the revert of G's mesh-sdk merge (#191): G's sdk stands again over reader release 3
Main reverted G's half merge (#189, reverted by 8afc3eb in #191) and then took the reader release's S1-S5, which
copied G's code. G's form holds where they differ (process_bus.go, seats.go, state.go and their tests); the
release's kept names stay so main's callers keep building: SeatViewPrefix beside SeatReadPrefix, and QueueInvoke's
empty strings on not-ok (with its test TestQueueInvoke). The tree differs from G's head f30dee54 only by those and
the release's two tests (objects cap option, seat states and stream kinds).

Builds: design 47 G (the milestone's sdk part, as at f30dee54)

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-13 12:49:56 +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 `modules/mesh-delivery-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", "modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json"},
{"mesh-delivery-checker", "mesh-delivery", "modules/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)
}
})
}
}