Imports rewritten to mesh-sdk's (beside, catalogue, overlay). Left in mesh-controller, which holds their modules: TestTheBuilderRequiresTheRegistryTheNpmSeatDelivers (foundation_manifests_test.go), TestGenesisAssignsTheBuildAgentWithNothingProvidingTheRegistry (genesis_registry_test.go, whole file), TestRouteProxyKeepsItsPublicAccountDirectory (public_issuer_test.go), TestEveryManifestInUseClaimsASeatTheMeshDefines (seats_test.go); with controller_is_a_process_test.go and genesis_image_test.go. moduleTree reads mesh-catalog only: mesh-sdk has no modules directory of its own. beside.Dir lays a repository's captured copy out once per process (a mutex and a map, os.MkdirTemp), new test TestTheCapturedCopyIsLaidOutOnce failed first (two directories). The captured copy is refreshed from the mains: mesh-catalog bb0fe93b, mesh-host cdcba9ca, only what these tests read; CAPTURED says how to move it. Unit level 1.16 s (bound 2 s).
72 lines
2.3 KiB
Go
72 lines
2.3 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"go/ast"
|
|
"go/parser"
|
|
"go/token"
|
|
"path/filepath"
|
|
"slices"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/internal/beside"
|
|
)
|
|
|
|
// The controller refuses a definition's resolved path by the node-engine's own rules, no more (novox/hq issue
|
|
// 496): the same lists, read here from mesh-host's internal/apply/placement_guard.go — in a merge check the clone
|
|
// beside it at the commit the mesh runs, elsewhere the copy captured in testdata/beside. When the engine's lists
|
|
// move, this fails until the controller's move with them, so the gate never refuses what the engine applies nor
|
|
// passes what it refuses by path alone.
|
|
func TestTheResolvedPathRulesAreTheNodeEnginesOwn(t *testing.T) {
|
|
file := filepath.Join(beside.Dir(t, "mesh-host"), "internal", "apply", "placement_guard.go")
|
|
parsed, err := parser.ParseFile(token.NewFileSet(), file, nil, 0)
|
|
if err != nil {
|
|
t.Fatalf("the node-engine's guard does not parse: %v", err)
|
|
}
|
|
lists := map[string][]string{}
|
|
consts := map[string]string{}
|
|
ast.Inspect(parsed, func(n ast.Node) bool {
|
|
spec, ok := n.(*ast.ValueSpec)
|
|
if !ok {
|
|
return true
|
|
}
|
|
for i, name := range spec.Names {
|
|
if i >= len(spec.Values) {
|
|
continue
|
|
}
|
|
switch v := spec.Values[i].(type) {
|
|
case *ast.CompositeLit:
|
|
for _, elt := range v.Elts {
|
|
if lit, ok := elt.(*ast.BasicLit); ok && lit.Kind == token.STRING {
|
|
s, _ := strconv.Unquote(lit.Value)
|
|
lists[name.Name] = append(lists[name.Name], s)
|
|
}
|
|
}
|
|
case *ast.BasicLit:
|
|
if v.Kind == token.STRING {
|
|
consts[name.Name], _ = strconv.Unquote(v.Value)
|
|
}
|
|
}
|
|
}
|
|
return true
|
|
})
|
|
for name, ours := range map[string][]string{
|
|
"protectedRoots": protectedRoots, "forbiddenBelow": forbiddenBelow, "engineTrees": engineTrees,
|
|
} {
|
|
theirs := lists[name]
|
|
if len(theirs) == 0 {
|
|
t.Errorf("the node-engine's guard names no %s any more; read it and say where its rule went", name)
|
|
continue
|
|
}
|
|
a, b := slices.Clone(ours), slices.Clone(theirs)
|
|
slices.Sort(a)
|
|
slices.Sort(b)
|
|
if !slices.Equal(a, b) {
|
|
t.Errorf("%s differs from the node-engine's:\n controller %v\n node-engine %v", name, a, b)
|
|
}
|
|
}
|
|
if consts["engineModule"] != engineModule {
|
|
t.Errorf("the node-engine's own module is %q there and %q here", consts["engineModule"], engineModule)
|
|
}
|
|
}
|