The graph left out only invoked verbs on a cycle, so a package's seat call word's kind-6 edge stayed on a cycle (the gate and the indexer, the gate and mesh-hand-acts at every SDK release). The module graph's LeaveOut now runs over the entries with each package's seat call words counted among the invokes of every module built against it, and what it leaves out joins each entry's LeftOut. Builds: design 47 G A-361, A-357; ADR 0614 §3 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
333 lines
19 KiB
Go
333 lines
19 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"os"
|
|
"slices"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
|
)
|
|
|
|
// Design 47 G §47, §121, A-208, A-212: an entry's edges between artifact references are written from its own words and
|
|
// the other entries of the revision, kinds 1 (an imported package), 2 (a `needs`), 3 (build module and bases), 4 (an
|
|
// awaited provision) and 6 (an invoked verb, none that lies on a cycle), each from B to A.
|
|
func TestAnEntryCarriesItsEdgesOfKindsOneToFourAndSix(t *testing.T) {
|
|
entries := map[string]meshcatalog.CatalogEntry{
|
|
"lib": {Module: "lib", Artifacts: []meshcatalog.Artifact{{Ref: "lib:go", Language: "go", Kind: "package", Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/lib/go"}}}},
|
|
"build-go": {Module: "build-go", Artifacts: []meshcatalog.Artifact{{Ref: "build-go:program", Language: "go"}},
|
|
Provides: []string{"builder"}, Serves: []string{"seat:mesh-builds.build"}},
|
|
"db": {Module: "db", Artifacts: []meshcatalog.Artifact{{Ref: "db:image", Kind: "image"}}, Provides: []string{"sql"}},
|
|
"cfg": {Module: "cfg", Artifacts: []meshcatalog.Artifact{{Ref: "cfg:archive", Kind: "archive"}}},
|
|
// A build seat's holder: the queue an asker names in its invokes, `seat:<seat>.accept.<queue>`, is its (A-231).
|
|
"node-go": {Module: "node-go", Artifacts: []meshcatalog.Artifact{{Ref: "node-go:program", Language: "go"}}, Serves: []string{"seat:node-build-go.steps"}},
|
|
"app": {Module: "app", Packages: map[string]string{"git.example/lib/go": "1.2.3"}, Bases: []string{"db"},
|
|
Toolchains: map[string]meshcatalog.BuildEdge{"go": {Module: "build-go"}},
|
|
Awaits: []string{"sql"}, Invokes: []string{"seat:mesh-builds.build", "seat:mesh-builds.cycle", "seat:node-build-go.accept.check"}, LeftOut: []string{"seat:mesh-builds.cycle"},
|
|
Manifest: map[string]any{"build": map[string]any{"artifacts": []any{map[string]any{"name": "program", "needs": []any{"cfg:archive", "nothing:here"}}}}},
|
|
Artifacts: []meshcatalog.Artifact{{Ref: "app:program", Language: "go"}}},
|
|
}
|
|
before := entries["app"]
|
|
got := WithEdges(entries)["app"].Edges
|
|
want := []meshcatalog.Edge{
|
|
{Kind: 1, From: "lib:go", To: "app:program", Stale: true, Word: "packages", Why: "git.example/lib/go"},
|
|
{Kind: 2, From: "cfg:archive", To: "app:program", Declared: true, Word: "needs", Why: "cfg:archive"},
|
|
{Kind: 3, From: "build-go:program", To: "app:program", Stale: true, Word: "toolchains", Why: "go"},
|
|
{Kind: 3, From: "db:image", To: "app:program", Stale: true, Word: "build.on", Why: "db"},
|
|
{Kind: 4, From: "db:image", To: "app:program", Word: "requires", Why: "sql"},
|
|
{Kind: 6, From: "build-go:program", To: "app:program", Word: "seat:mesh-builds.build", Why: "seat:mesh-builds.build"},
|
|
{Kind: 6, From: "node-go:program", To: "app:program", Word: "seat:node-build-go.accept.check", Why: "seat:node-build-go.accept.check"},
|
|
}
|
|
if !slices.Equal(got, want) {
|
|
t.Errorf("edges\n got %+v\nwant %+v", got, want)
|
|
}
|
|
if len(before.Edges) != 0 || len(entries["app"].Edges) != 0 {
|
|
t.Errorf("the entries given were changed")
|
|
}
|
|
}
|
|
|
|
// Design 47 G A-208: a revision kept holds each entry with its edges, so the builder and the assigner read them from the entry.
|
|
func TestAKeptRevisionHoldsTheEdgesOfItsEntries(t *testing.T) {
|
|
ctx := context.Background()
|
|
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), Now: func() time.Time { return time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC) }}
|
|
err := ix.KeepBranchEntries(ctx, "main", 1, map[string]meshcatalog.CatalogEntry{
|
|
"b": {Module: "b", Manifest: map[string]any{}, Artifacts: []meshcatalog.Artifact{{Ref: "b:p"}}, Serves: []string{"seat:s.v"}},
|
|
"a": {Module: "a", Manifest: map[string]any{}, Artifacts: []meshcatalog.Artifact{{Ref: "a:p"}}, Invokes: []string{"seat:s.v"}},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, entries, err := ReadRevision(ctx, ix.Revisions, "trunk.1")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, e := range entries {
|
|
if e.Module == "a" && (len(e.Edges) != 1 || e.Edges[0].Kind != 6 || e.Edges[0].From != "b:p" || e.Edges[0].To != "a:p") {
|
|
t.Errorf("the kept entry of a holds %+v, want one edge of kind 6 from b:p", e.Edges)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Design 47 G §558, A-208: a verb invoked in the long form {verb, fields} gives its kind-6 edge the fields it relies on,
|
|
// read by the second reader release; the short form names none.
|
|
func TestAKindSixEdgeNamesTheFieldsALongFormInvokeRelies(t *testing.T) {
|
|
entries := map[string]meshcatalog.CatalogEntry{
|
|
"holder": {Module: "holder", Artifacts: []meshcatalog.Artifact{{Ref: "holder:p"}}, Serves: []string{"seat:s.list", "seat:s.get"}},
|
|
"user": {Module: "user", Artifacts: []meshcatalog.Artifact{{Ref: "user:p"}}, Invokes: []string{"seat:s.get", "seat:s.list"},
|
|
Manifest: map[string]any{"module": "user", "version": "1.0", "invokes": []any{"seat:s.get", map[string]any{"verb": "seat:s.list", "fields": []any{"binding", "node"}}}}},
|
|
}
|
|
got := WithEdges(entries)["user"].Edges
|
|
if len(got) != 2 || got[0].Why != "seat:s.get" || got[1].Why != "seat:s.list fields binding, node" || got[1].Word != "seat:s.list" {
|
|
t.Errorf("edges %+v, want the short verb as it is and the long form with its fields", got)
|
|
}
|
|
}
|
|
|
|
// Design 47 G §605, §545, A-208: a module built against a package whose artifact takes `calls` is ordered after the artifact
|
|
// that `states` each word, by an edge of kind 6 naming the word; a module built against no such package has none. A-357: a
|
|
// call word in the invokes form orders it after the verb's server, as from `invokes`, and the server after none of its own.
|
|
func TestAModuleBuiltOnAPackageThatCallsTheToolRunnerIsOrderedAfterTheArtifactThatStatesTheWords(t *testing.T) {
|
|
artifactsOf := func(module string, art map[string]any) map[string]any {
|
|
return map[string]any{"module": module, "build": map[string]any{"artifacts": []any{art}}}
|
|
}
|
|
entries := map[string]meshcatalog.CatalogEntry{
|
|
"sdk": {Module: "sdk", Artifacts: []meshcatalog.Artifact{{Ref: "sdk:go", Kind: "package", Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/sdk/go"}}},
|
|
Manifest: artifactsOf("sdk", map[string]any{"name": "go", "calls": []any{"put-sessions", "finding-calls", "seat:mesh-catalog.registrations"}})},
|
|
"catalog": {Module: "catalog", Artifacts: []meshcatalog.Artifact{{Ref: "catalog:program", Language: "go"}}, Serves: []string{"seat:mesh-catalog.registrations"},
|
|
Packages: map[string]string{"git.example/sdk/go": "1.0.4"}},
|
|
"runner": {Module: "runner", Artifacts: []meshcatalog.Artifact{{Ref: "runner:runtime"}},
|
|
Manifest: artifactsOf("runner", map[string]any{"name": "runtime", "states": []any{"put-sessions"}})},
|
|
"app": {Module: "app", Artifacts: []meshcatalog.Artifact{{Ref: "app:program", Language: "go"}}, Packages: map[string]string{"git.example/sdk/go": "1.0.4"}},
|
|
"other": {Module: "other", Artifacts: []meshcatalog.Artifact{{Ref: "other:program", Language: "go"}}},
|
|
}
|
|
got := WithEdges(entries)
|
|
var six []meshcatalog.Edge
|
|
for _, e := range got["app"].Edges {
|
|
if e.Kind == 6 {
|
|
six = append(six, e)
|
|
}
|
|
}
|
|
want := []meshcatalog.Edge{{Kind: 6, From: "catalog:program", To: "app:program", Word: "seat:mesh-catalog.registrations", Why: "calls of git.example/sdk/go"},
|
|
{Kind: 6, From: "runner:runtime", To: "app:program", Word: "put-sessions", Why: "calls of git.example/sdk/go"}}
|
|
if !slices.Equal(six, want) {
|
|
t.Errorf("app's edges of kind 6 are %+v, want %+v", six, want)
|
|
}
|
|
if slices.ContainsFunc(got["catalog"].Edges, func(e meshcatalog.Edge) bool { return e.From == "catalog:program" }) {
|
|
t.Errorf("the verb's server is ordered after itself: %+v", got["catalog"].Edges)
|
|
}
|
|
if len(got["other"].Edges) != 0 {
|
|
t.Errorf("other builds on no such package, its edges %+v", got["other"].Edges)
|
|
}
|
|
}
|
|
|
|
// Design 47 G A-361: a package's seat call words count among the invokes of every module built against it when the graph
|
|
// leaves out the edges on a cycle, so a call word's edge on a cycle is left out like an invoked verb's (the gate and the
|
|
// indexer: the gate invokes the indexer's verb, the indexer's SDK calls the gate's), and an edge off the cycle stays.
|
|
func TestASeatCallWordsEdgeOnACycleIsLeftOutLikeAnInvokedVerbs(t *testing.T) {
|
|
sdk := map[string]any{"module": "sdk", "build": map[string]any{"artifacts": []any{map[string]any{"name": "go",
|
|
"calls": []any{"seat:mesh-delivery.source", "seat:mesh-catalog.registrations"}}}}}
|
|
pkgs := map[string]string{"git.example/sdk/go": "1.0.4"}
|
|
entries := map[string]meshcatalog.CatalogEntry{
|
|
"sdk": {Module: "sdk", Artifacts: []meshcatalog.Artifact{{Ref: "sdk:go", Kind: "package", Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/sdk/go"}}},
|
|
Manifest: sdk},
|
|
"gate": {Module: "gate", Artifacts: []meshcatalog.Artifact{{Ref: "gate:program", Language: "go"}}, Serves: []string{"seat:mesh-delivery.source"},
|
|
Invokes: []string{"seat:mesh-catalog.registrations"}},
|
|
"indexer": {Module: "indexer", Artifacts: []meshcatalog.Artifact{{Ref: "indexer:program", Language: "go"}}, Serves: []string{"seat:mesh-catalog.registrations"},
|
|
Packages: pkgs},
|
|
"app": {Module: "app", Artifacts: []meshcatalog.Artifact{{Ref: "app:program", Language: "go"}}, Packages: pkgs},
|
|
}
|
|
got := WithEdges(entries)
|
|
for _, m := range []string{"gate", "indexer"} {
|
|
for _, e := range got[m].Edges {
|
|
if e.Kind == 6 {
|
|
t.Errorf("%s keeps the edge %+v, which lies on the cycle gate-indexer", m, e)
|
|
}
|
|
}
|
|
}
|
|
if !slices.Contains(got["indexer"].LeftOut, "seat:mesh-delivery.source") || !slices.Contains(got["gate"].LeftOut, "seat:mesh-catalog.registrations") {
|
|
t.Errorf("left out: indexer %v, gate %v, want each one's word on the cycle", got["indexer"].LeftOut, got["gate"].LeftOut)
|
|
}
|
|
var six []meshcatalog.ArtifactRef
|
|
for _, e := range got["app"].Edges {
|
|
if e.Kind == 6 {
|
|
six = append(six, e.From)
|
|
}
|
|
}
|
|
if !slices.Equal(six, []meshcatalog.ArtifactRef{"gate:program", "indexer:program"}) || len(got["app"].LeftOut) != 0 {
|
|
t.Errorf("app's edges of kind 6 come from %v, left out %v, want both servers and none left out", six, got["app"].LeftOut)
|
|
}
|
|
if len(entries["gate"].LeftOut) != 0 {
|
|
t.Error("the entries given were changed")
|
|
}
|
|
}
|
|
|
|
func actingEntries() map[string]meshcatalog.CatalogEntry {
|
|
rule := func(seat, step, on string) meshcatalog.ActingRule {
|
|
return meshcatalog.ActingRule{Seat: seat, Step: step, On: on}
|
|
}
|
|
return map[string]meshcatalog.CatalogEntry{
|
|
"grants": {Module: "grants", Artifacts: []meshcatalog.Artifact{{Ref: "grants:program", Language: "go"}},
|
|
Packages: map[string]string{"git.example/lib/go": "1.0.0"}, Toolchains: map[string]meshcatalog.BuildEdge{"go": {Module: "build-go"}},
|
|
Acts: []meshcatalog.ActingRule{rule("mesh-grants", "grant", "every"), rule("mesh-grants", "take-in", "every"), rule("mesh-grants", "validate", "")}},
|
|
"lib": {Module: "lib", Artifacts: []meshcatalog.Artifact{{Ref: "lib:go", Language: "go", Kind: "package", Package: &meshcatalog.ArtifactPackage{Ecosystem: EcosystemGo, Name: "git.example/lib/go"}}}},
|
|
"build-go": {Module: "build-go", Artifacts: []meshcatalog.Artifact{{Ref: "build-go:program", Language: "go"}}, Acts: []meshcatalog.ActingRule{rule("node-build-go", "build", "go")}},
|
|
"composer": {Module: "composer", Artifacts: []meshcatalog.Artifact{{Ref: "composer:program", Language: "go"}}, Acts: []meshcatalog.ActingRule{rule("mesh-compose", "compose", "kind:image")}},
|
|
"db": {Module: "db", Artifacts: []meshcatalog.Artifact{{Ref: "db:image", Kind: "image"}}},
|
|
"web": {Module: "web", Artifacts: []meshcatalog.Artifact{{Ref: "web:program", Language: "typescript"}}},
|
|
"bare": {Module: "bare"},
|
|
}
|
|
}
|
|
|
|
// Design 47 G §711: an acting rule of a step that acts on a delivered version gives kind 5 from the acting entry's delivered
|
|
// artifact to each other entry the rule's `on` matches, with the word `acts` and the why `<seat> <step>`; none to the entry
|
|
// itself, to one it is built from (a package, a build module), to one with no artifact; take-in, validate and build give none.
|
|
func TestAnActingRuleGivesKindFiveFromTheActingEntryToTheEntriesItActsOn(t *testing.T) {
|
|
got := WithEdges(actingEntries())
|
|
five := func(m string) []meshcatalog.Edge {
|
|
var out []meshcatalog.Edge
|
|
for _, e := range got[m].Edges {
|
|
if e.Kind == 5 {
|
|
out = append(out, e)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
grant := func(to string) meshcatalog.Edge {
|
|
return meshcatalog.Edge{Kind: 5, From: "grants:program", To: to, Word: "acts", Why: "mesh-grants grant"}
|
|
}
|
|
for module, want := range map[string][]meshcatalog.Edge{
|
|
"web": {grant("web:program")},
|
|
"composer": {grant("composer:program")},
|
|
"db": {{Kind: 5, From: "composer:program", To: "db:image", Word: "acts", Why: "mesh-compose compose"}, grant("db:image")},
|
|
"build-go": nil, // grants is built with it
|
|
"lib": nil, // and from it
|
|
"grants": nil, // never to itself
|
|
"bare": nil, // no artifact
|
|
} {
|
|
if g := five(module); !slices.Equal(g, want) {
|
|
t.Errorf("kind 5 into %s: got %+v, want %+v", module, g, want)
|
|
}
|
|
}
|
|
for _, e := range got["web"].Edges {
|
|
if e.Stale || e.Declared {
|
|
t.Errorf("an edge of kind 5 only orders: %+v", e)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Design 47 G §711: `acts` is filled from the definitions of each seat the manifest claims, as {seat, step, on, bound},
|
|
// sorted by seat then step; an entry claiming no seat with a rule has none.
|
|
func TestAnEntryCarriesTheActingRulesOfTheSeatsItClaims(t *testing.T) {
|
|
claims := func(seats ...string) map[string]any {
|
|
var list []any
|
|
for _, s := range seats {
|
|
list = append(list, map[string]any{"name": s})
|
|
}
|
|
return map[string]any{"module": "m", "version": "1.0", "claims": list}
|
|
}
|
|
defs := map[string]seatdef.Definition{
|
|
"mesh-grants": {Acts: []seatdef.ActingRule{{Step: "grant", On: "every", Bound: "5m"}, {Step: "build", On: "go"}}},
|
|
"a-seat": {Acts: []seatdef.ActingRule{{Step: "place"}}},
|
|
"unclaimed": {Acts: []seatdef.ActingRule{{Step: "compose"}}},
|
|
"plain": {},
|
|
}
|
|
got := WithActs(map[string]meshcatalog.CatalogEntry{
|
|
"m": {Module: "m", Manifest: claims("mesh-grants", "a-seat", "plain")},
|
|
"other": {Module: "other", Manifest: claims("plain")},
|
|
}, defs)
|
|
want := []meshcatalog.ActingRule{{Seat: "a-seat", Step: "place"}, {Seat: "mesh-grants", Step: "build", On: "go"}, {Seat: "mesh-grants", Step: "grant", On: "every", Bound: "5m"}}
|
|
if !slices.Equal(got["m"].Acts, want) {
|
|
t.Errorf("acts %+v, want %+v", got["m"].Acts, want)
|
|
}
|
|
if got["other"].Acts != nil {
|
|
t.Errorf("a module claiming no seat with a rule has acts %+v", got["other"].Acts)
|
|
}
|
|
}
|
|
|
|
// Design 47 G §711: the indexer reads the rules from the seat definitions it keeps when it keeps a revision, so the kept entry
|
|
// carries its acts and the entries it acts on carry the edge.
|
|
func TestAKeptRevisionHoldsTheActsAndTheKindFiveEdges(t *testing.T) {
|
|
ctx := context.Background()
|
|
defs := newMem()
|
|
_ = defs.Create(ctx, "mesh-grants.trunk", []byte(`{"seat":"mesh-grants","source":"trunk","digest":"d","definition":{"seat":"mesh-grants","acts":[{"step":"grant","on":"every"}]}}`))
|
|
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), SeatDefinitions: defs, Now: func() time.Time { return time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC) }}
|
|
err := ix.KeepBranchEntries(ctx, "main", 1, map[string]meshcatalog.CatalogEntry{
|
|
"grants": {Module: "grants", Manifest: map[string]any{"module": "grants", "version": "1.0", "claims": []any{map[string]any{"name": "mesh-grants"}}}, Artifacts: []meshcatalog.Artifact{{Ref: "grants:p"}}},
|
|
"app": {Module: "app", Manifest: map[string]any{}, Artifacts: []meshcatalog.Artifact{{Ref: "app:p"}}},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
_, entries, err := ReadRevision(ctx, ix.Revisions, "trunk.1")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, e := range entries {
|
|
switch e.Module {
|
|
case "grants":
|
|
if len(e.Acts) != 1 || e.Acts[0].Seat != "mesh-grants" || e.Acts[0].Step != "grant" {
|
|
t.Errorf("grants holds acts %+v", e.Acts)
|
|
}
|
|
case "app":
|
|
if len(e.Edges) != 1 || e.Edges[0].Kind != 5 || e.Edges[0].From != "grants:p" || e.Edges[0].Why != "mesh-grants grant" {
|
|
t.Errorf("app holds edges %+v, want one of kind 5 from grants:p", e.Edges)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// A-326, A-333 (design 47 G §49, §51): a cycle through a build module's own inputs is broken at its running version and
|
|
// allowed, as are a cycle of package edges alone and a cycle of delivery edges alone; any other cycle with a build edge is
|
|
// refused, naming every artifact on it. Today's trunk catalogue and G's own (the entries of G's dry run, 2026-11-13, kept
|
|
// in testdata with what the edges are computed from) are accepted.
|
|
func TestACycleWithABuildEdgeIsRefusedUnlessABuildSeatsRunningVersionBreaksIt(t *testing.T) {
|
|
builder := meshcatalog.CatalogEntry{Module: "mesh-build-go", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-build-go:files", Language: "go"}},
|
|
Acts: []meshcatalog.ActingRule{{Seat: "node-build-go", Step: seatdef.StepBuild, On: "go"}}}
|
|
handActs := meshcatalog.CatalogEntry{Module: "mesh-hand-acts", Artifacts: []meshcatalog.Artifact{{Ref: "mesh-hand-acts:tools", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 3, From: "mesh-build-go:files", To: "mesh-hand-acts:tools", Word: "toolchains", Why: "go"}}}
|
|
trunkCycle := builder
|
|
trunkCycle.Edges = []meshcatalog.Edge{{Kind: 6, From: "mesh-hand-acts:tools", To: "mesh-build-go:files", Word: "seat:mesh-hand-acts.hand-act"}}
|
|
a := meshcatalog.CatalogEntry{Module: "a", Artifacts: []meshcatalog.Artifact{{Ref: "a:go", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 1, From: "b:go", To: "a:go", Word: "packages"}}}
|
|
b := meshcatalog.CatalogEntry{Module: "b", Artifacts: []meshcatalog.Artifact{{Ref: "b:go", Language: "go"}},
|
|
Edges: []meshcatalog.Edge{{Kind: 1, From: "a:go", To: "b:go", Word: "packages"}}}
|
|
noSeat := trunkCycle
|
|
noSeat.Acts = nil
|
|
verbsOnly := meshcatalog.CatalogEntry{Module: "c", Artifacts: []meshcatalog.Artifact{{Ref: "c:go"}}, Edges: []meshcatalog.Edge{{Kind: 6, From: "d:go", To: "c:go"}}}
|
|
verbsBack := meshcatalog.CatalogEntry{Module: "d", Artifacts: []meshcatalog.Artifact{{Ref: "d:go"}}, Edges: []meshcatalog.Edge{{Kind: 4, From: "c:go", To: "d:go"}}}
|
|
for _, c := range []struct {
|
|
name string
|
|
entries []meshcatalog.CatalogEntry
|
|
want []meshcatalog.ArtifactRef
|
|
}{
|
|
{"the trunk catalogue's cycle through a build module's own inputs", []meshcatalog.CatalogEntry{trunkCycle, handActs}, nil},
|
|
{"two artifacts each needing the other's new package, package edges alone", []meshcatalog.CatalogEntry{a, b}, nil},
|
|
{"the same cycle from a module that holds no build seat", []meshcatalog.CatalogEntry{noSeat, handActs},
|
|
[]meshcatalog.ArtifactRef{"mesh-build-go:files", "mesh-hand-acts:tools", "mesh-build-go:files"}},
|
|
{"a cycle of delivery edges alone", []meshcatalog.CatalogEntry{verbsOnly, verbsBack}, nil},
|
|
} {
|
|
entries := map[string]meshcatalog.CatalogEntry{}
|
|
for _, e := range c.entries {
|
|
entries[e.Module] = e
|
|
}
|
|
if got := RefusedCycle(entries); !slices.Equal(got, c.want) {
|
|
t.Errorf("%s: refused %v, want %v", c.name, got, c.want)
|
|
}
|
|
}
|
|
for _, name := range []string{"catalog-entries-trunk-2026-11-13", "catalog-entries-47-G-2026-11-13"} {
|
|
raw, err := os.ReadFile("testdata/" + name + ".json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var entries map[string]meshcatalog.CatalogEntry
|
|
if err := json.Unmarshal(raw, &entries); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := RefusedCycle(WithEdges(entries)); got != nil {
|
|
t.Errorf("%s: refused %v, want the catalogue accepted", name, got)
|
|
}
|
|
}
|
|
}
|