Files
mesh-controller/internal/ownmanifest/seats_test.go
T
jschoubben a6386ff23a Decode manifests in tests and pin the mesh-sdk that no longer holds the judge
Issue 1585, S18/S19: the judge's tests live in mesh-delivery now, so an assertion that only tested judging goes
and every test that builds a manifest decodes it.

Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
2026-11-01 02:40:39 +01:00

51 lines
1.7 KiB
Go

package ownmanifest
import (
"os"
"path/filepath"
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"github.com/novox/mesh-controller/internal/beside"
)
// Every module in use claims a seat in the set, so closing it refuses nothing that runs.
//
// Read from the catalogue (internal/beside) and from this repository's own manifest, the two places a
// manifest lives (ADR 0069). The private-network module's manifest is composed in code, and its claim
// is checked where it is composed.
func TestEveryManifestInUseClaimsASeatTheMeshDefines(t *testing.T) {
paths, _ := filepath.Glob(filepath.Join(beside.Catalogue(t), "*", "module.json"))
if len(paths) == 0 {
t.Fatal("no manifests in the catalogue, so this proved nothing")
}
root := beside.Dir(t, "mesh-catalog")
paths = append(paths, "../../module.json")
var checked int
for _, path := range paths {
// The SDK's claimProblems is unexported; the parser runs it on every manifest whose claims are well formed
// (go/catalogue manifest.go), so a manifest that parses claims only seats the mesh defines or declares. A
// catalogue manifest is judged as the merge check judges it, against the predefined list at the root of the tree it
// is read in (ADR 0348 §7, issue 914); this repository's own is judged alone.
var m catalogue.Manifest
var err error
if path == "../../module.json" {
var raw []byte
if raw, err = os.ReadFile(path); err != nil {
t.Fatal(err)
}
m, err = catalogue.Decode(raw)
} else {
m, err = catalogue.ReadTreeManifest(root, filepath.Dir(path))
}
if err != nil {
t.Errorf("%s: %v", path, err)
continue
}
checked += len(m.Claims)
}
if checked == 0 {
t.Fatal("no claims were checked, so this proved nothing")
}
}