Files
mesh-controller/internal/inventory/buildinput_test.go
T
jschoubben c3b88b9148 Rename mesh-control -> mesh-controller, substrate -> foundation
One name per thing, per the HQ glossary: the module/container/image/binary/repo
becomes mesh-controller, the seat the-controller, and the store+broker pair the
foundation (embedded base bundles, default template and example lock renamed with
their go:embed directives). No behaviour change — a pure vocabulary rename.

Claude-Session: https://claude.ai/code/session_01D6qtiYU3P9jk3pnAXyAFyx
2026-09-16 18:40:40 +02:00

45 lines
1.7 KiB
Go

package inventory
import (
"testing"
"github.com/novox/mesh-controller/internal/catalogue"
)
// The image every module is compiled on top of is built and never run.
func TestAThingBuiltAndNeverRunIsABuildInput(t *testing.T) {
m := catalogue.Manifest{
Module: "mesh-tools",
Build: &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "runtime", Kind: "image"}}},
}
if !IsBuildInput(m) {
t.Fatal("a module that builds an artifact and places nothing is assignable, so `assign` " +
"succeeds and the machine is sent a declaration containing nothing of it")
}
}
// The private network declares no resources either, and is assigned to every machine that has to
// reach another one.
//
// **This is the one that matters.** Reading "no resources" as "runs nowhere" refused it, and a
// four-machine bed stopped dead at the first assignment — the control plane computes its resources
// when it composes a declaration, so there is nothing in its manifest to see.
func TestTheMeshsOwnNetworkIsNotABuildInput(t *testing.T) {
if IsBuildInput(catalogue.Manifest{Module: "networking"}) {
t.Fatal("the private network was refused as a thing that runs nowhere; nothing could " +
"then reach anything else")
}
}
// And an ordinary module that both builds and runs is assignable, which is most of them.
func TestAModuleThatBuildsAndRunsIsAssignable(t *testing.T) {
m := catalogue.Manifest{
Module: "postgres",
Build: &catalogue.Build{Artifacts: []catalogue.Artifact{{Name: "runtime", Kind: "image"}}},
Resources: []map[string]any{{"id": "server", "type": "container"}},
}
if IsBuildInput(m) {
t.Fatal("a module that builds something and also runs it was refused")
}
}