Files
mesh-controller/internal/inventory/buildinput_test.go
T
mesh-tools bfe7fe1530 Pin mesh-sdk at 14fd5cb6 (R4a's merge) and take the catalogue, overlay and validator from it, s to inventory (issue 1381, 4 of 6 import swaps)
go.mod and go.sum move to mesh-sdk 14fd5cb68fd1, the commit on its main that holds go/catalogue, go/overlay and go/validate (ADR 0453 clause 2); vendor/modules.txt follows in the last of the six commits.
2026-10-20 08:26:01 +00:00

45 lines
1.7 KiB
Go

package inventory
import (
"testing"
"git.novox.be/novox/mesh-sdk/go/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")
}
}