Files
mesh-delivery/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/names_test.go
T
jschoubben 07c13b0b9c B1 (builder): the builder's own buckets are named from its credential's module
The versions, bounds, reserved, publish-queue, acted, toolchains-heard and instances buckets were constants naming
mesh-delivery-builder; ownBucketsOf takes them from the module the credential names.

Builds: design 47 G A-296, §428

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 23:32:42 +01:00

58 lines
2.0 KiB
Go

package main
import (
"encoding/json"
"os"
"slices"
"strings"
"testing"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/buildrun"
)
// TestTheNamesAreTheManifests: the holders and buckets the builder names are its manifest's `reads` (the gate's source, the
// build modules' steps and toolchains) and its `consumes` of the indexer's and assigner's views, since no contract names a
// holder (novox/hq ADR 0634 §1).
func TestTheNamesAreTheManifests(t *testing.T) {
raw, err := os.ReadFile("../../module.json")
if err != nil {
t.Fatal(err)
}
var m struct {
Reads []string `json:"reads"`
Consumes []string `json:"consumes"`
}
if err := json.Unmarshal(raw, &m); err != nil {
t.Fatal(err)
}
for _, read := range []string{
"seat:node-build-go.steps", "seat:node-build-image.steps", "seat:node-build-node.steps",
} {
if !slices.Contains(m.Reads, read) {
t.Errorf("the builder reads %s, its manifest's reads are %v", read, m.Reads)
}
}
// The catalog half (design 47 G §348, §614) is followed through the seat, and no state of the indexer is.
for _, c := range m.Consumes {
if strings.HasPrefix(c, "mesh-delivery-indexer.") {
t.Errorf("the builder follows %s, an indexer state, its manifest consumes it", c)
}
}
for _, view := range []string{"mesh-catalog.catalog-revision", "mesh-catalog.registration-changed", "mesh-delivery.source-moved", "seat:mesh-module-assigner.views.assignments"} {
if !slices.Contains(m.Consumes, view) {
t.Errorf("the builder follows %s, its manifest consumes %v", view, m.Consumes)
}
}
for want, got := range map[string]string{
"mesh-build-go_steps": buildrun.StepsBucket("mesh-build-go"),
ownBucketsOf("acme-builder").toolchainsHeard: "acme-builder_toolchains-heard",
ownBucketsOf("acme-builder").bounds: "acme-builder_bounds",
ownBucketsOf("acme-builder").versions: "acme-builder_versions",
ownBucketsOf("acme-builder").instances: "acme-builder_instances",
} {
if want != got {
t.Errorf("a bucket is %q, want %q", got, want)
}
}
}