The builder adopts meshcatalogclient's branch follower on its views reader (A-5, A-15): the modules, their manifests (kept from the entry that holds them, by its digest), their packages and each package's name in its ecosystem are read from the catalog half's entries, never the indexer's modules, manifests, candidates and packages views; an entry of a branch other than the module's first builds its fingerprint and supersedes only its own branch's older one; the start's sweep runs once every followed half's first view is in; the builder's tools bundle reads package names through the same follower. A run's candidate is no input of the builder (A-84): its read of the indexer's candidates view goes, and the entry point for a run's build ask is not built (no line gives the ask's form). The seats' events the builder's own handler takes are named per seat so the follower's events have one taker. Builds: design 47 G §348, §479, §614, A-5, A-15, A-84 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
56 lines
2.3 KiB
Go
56 lines
2.3 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)
|
|
}
|
|
}
|