Files
mesh-delivery/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/build_test.go
T
jschoubben ac153497f6 Join 9: the builder reads the build seats' steps in seat form, at the seat's holder (A-116, A-128)
module.json reads seat:node-build-<language>.steps as the checker and the watchman do; the
tools bundle reads <holder>.steps, the holder found by seatlist.HolderOf where it is read.

Builds: design 47 G A-116, A-126, A-128

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 02:06:19 +01:00

57 lines
2.5 KiB
Go

package main
import (
"encoding/json"
"errors"
"strings"
"testing"
"mesh-delivery-builder/internal/build"
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
)
// Design 47 G §589, A-87: the tools bundle reads each watched branch's newest catalog graph entry of the module from the catalog
// half itself: the verb registrations for the branches, the verb revision for each branch's view.
func TestNewestIsReadFromTheCatalogHalfOfEachWatchedBranch(t *testing.T) {
fp := map[string]string{"main": "src2:" + strings.Repeat("1", 64), "feature": "src2:" + strings.Repeat("2", 64)}
ask := func(key string, body any) (json.RawMessage, error) {
switch key {
case meshcatalogclient.RegistrationsVerb:
return json.Marshal(meshcatalog.RegistrationsAnswer{Registrations: []meshcatalog.Registration{{Module: "m", Branches: []string{"main", "feature"}}}})
case meshcatalogclient.RevisionVerb:
in := body.(meshcatalog.RevisionInput)
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Revision: 3, Kind: meshcatalogclient.KindTrunk},
Entries: []meshcatalog.CatalogEntry{{Module: "m", Fp: fp[in.Branch]}, {Module: "z", Fp: "src2:" + strings.Repeat("9", 64)}}})
}
t.Fatalf("asked %s", key)
return nil, nil
}
got, err := newestVia(ask)("m")
if err != nil || len(got) != 2 || got["main"] != fp["main"] || got["feature"] != fp["feature"] {
t.Fatalf("newest = %v, %v, want each branch's entry fingerprint whole", got, err)
}
}
// A build seat's steps are read in its holder's state, the holder found where it is read (design 47 G A-128); a seat with no
// holder found reads as an error.
func TestABuildSeatsStepsAreReadInItsHoldersState(t *testing.T) {
var named []string
steps := stepsOfHolder(func(seat string) (string, error) {
if seat == "node-build-go" {
return "mesh-build-go", nil
}
return "", errors.New("no holder")
}, func(name string) build.StateRead {
named = append(named, name)
return build.StateRead{Keys: func() ([]string, error) { return []string{"k"}, nil }}
})
if ks, err := steps("node-build-go").Keys(); err != nil || len(ks) != 1 || len(named) != 1 || named[0] != "mesh-build-go.steps" {
t.Errorf("read %v (keys %v, %v); want the holder's mesh-build-go.steps", named, ks, err)
}
if _, err := steps("node-build-node").Keys(); err == nil || !strings.Contains(err.Error(), "node-build-node") {
t.Errorf("a seat with no holder reads %v; want an error naming it", err)
}
}