Files
mesh-delivery/modules/mesh-delivery-builder/internal/versions/entrynames_test.go
T
jschoubben 1eb481ccc8 Builder: the manifest names no other module, the floor reads the seat git and the catalog half
The floor's tags are the seat git's verb tags and its requirements what the catalog half's entries
name for the package (indexer_requirements and the forge bridge's bridge_tags go from code and
manifest); a catalog revision the builder hears wakes a silent floor (the forge stream's consume
and its wake go). The guard test says A-107 relaxes ADR 0437 section 8 for a seat's verbs and
accepted kinds. The integration bed creates the state bounds the step bounds are kept in.
The assignments view's seat form (A-119 (3)) is not built here.

Builds: design 47 G §7, A-82, A-107, A-119
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 01:18:40 +01:00

75 lines
3.2 KiB
Go

package versions
import (
"context"
"reflect"
"testing"
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
)
func named(module, artifact, name string) meshcatalog.CatalogEntry {
return meshcatalog.CatalogEntry{Module: module, Artifacts: []meshcatalog.Artifact{
{Ref: module + ":" + artifact, Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: "go", Name: name}}}}
}
// TestPackageNamesAreReadFromTheCatalogHalfsEntries: a package's name in its ecosystem is the name the entry of its module gives the
// artifact (design 47 G §348, §676), the module and artifact a name is built from are the entries carrying it, and a name two
// entries carry is an error naming both (§491); no state of the indexer is read.
func TestPackageNamesAreReadFromTheCatalogHalfsEntries(t *testing.T) {
entries := func() []meshcatalog.CatalogEntry {
return []meshcatalog.CatalogEntry{named("mesh-sdk", "go", "git.novox.be/novox/mesh-sdk/go"), named("netcheck", "lib", "netcheck"),
named("twin-a", "lib", "twin"), named("twin-b", "lib", "twin"), {Module: "bare"}}
}
ctx := context.Background()
for _, c := range []struct {
module, artifact string
name string
known bool
}{
{"mesh-sdk", "go", "git.novox.be/novox/mesh-sdk/go", true},
{"netcheck", "lib", "netcheck", true},
{"netcheck", "other", "", false},
{"bare", "lib", "", false},
{"unknown", "lib", "", false},
} {
got, known, err := NamesFrom(entries)(ctx, c.module, c.artifact)
if err != nil || got != c.name || known != c.known {
t.Errorf("NamesFrom(%s/%s) = %q, %v, %v; want %q, %v", c.module, c.artifact, got, known, err, c.name, c.known)
}
}
module, artifact, found, err := ModuleFrom(entries)(ctx, "netcheck")
if module != "netcheck" || artifact != "lib" || !found || err != nil {
t.Errorf("ModuleFrom(netcheck) = %q, %q, %v, %v", module, artifact, found, err)
}
if _, _, found, err := ModuleFrom(entries)(ctx, "nobody"); found || err != nil {
t.Errorf("ModuleFrom(nobody) = %v, %v; want none", found, err)
}
if _, _, _, err := ModuleFrom(entries)(ctx, "twin"); err == nil {
t.Error("ModuleFrom(twin): two entries carry it, want an error")
}
got, _ := CarriersFrom(entries)(ctx, "twin")
if want := []Built{{"twin-a", "lib"}, {"twin-b", "lib"}}; !reflect.DeepEqual(got, want) {
t.Errorf("CarriersFrom(twin) = %v, want %v", got, want)
}
}
// Design 47 G A-119: the floor's requirements are what the catalog half's entries name for the package, each version once.
func TestRequirementsFromAreTheVersionsEntriesNameForAPackage(t *testing.T) {
entries := func() []meshcatalog.CatalogEntry {
return []meshcatalog.CatalogEntry{
{Module: "a", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa", "y": "v1.0.0"}},
{Module: "b", Packages: map[string]string{"x/sdk": "v0.0.0-2026-bbb"}},
{Module: "c", Packages: map[string]string{"x/sdk": "v0.0.0-2026-aaa"}},
{Module: "d"},
}
}
got, err := RequirementsFrom(entries)(context.Background(), "x/sdk")
if err != nil || !reflect.DeepEqual(got, []string{"v0.0.0-2026-aaa", "v0.0.0-2026-bbb"}) {
t.Errorf("requirements = %v, %v", got, err)
}
if got, _ := RequirementsFrom(entries)(context.Background(), "none"); len(got) != 0 {
t.Errorf("a package no entry names has requirements %v", got)
}
}