Files
mesh-delivery/modules/mesh-delivery-indexer/internal/index/open_asks_test.go
T
jschoubben f474987827 I13b: the versions fill, the event versions-filled and the builder's fill wait go
The indexer's first fill of the versions from builder_versions was the only
part that said versions-filled, and the numbering it served is gone. So the
fill, its edges and its call go from the indexer, the event leaves the seat
mesh-catalog's definition, its fixture and the generated contracts (the
seat's form rises to 6), and the builder neither hears it nor waits on it:
it reserves from its own reservations alone.

Builds: design 47 H2 H-A-552, H-A-532 (DQ-9, DMC-5), H §756, G §372
2026-11-23 12:26:20 +01:00

79 lines
3.4 KiB
Go

package index
import (
"context"
"encoding/json"
"fmt"
"testing"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo"
"git.novox.be/novox/mesh-sdk/go/seatdef"
)
// A-190: a kept call is asked again only while what it serves still stands; each of the indexer's three has its predicate.
func TestKeptCallsOpenWhileTheirAskServesSomething(t *testing.T) {
ctx := context.Background()
t.Run("the seed's candidate and the versions' module are in the newest trunk revision", func(t *testing.T) {
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20)}
keep := func(n int64, fp string) {
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: n, Kind: "trunk"}, map[string]meshcatalog.CatalogEntry{"avahi": {Module: "avahi", Fp: fp, Manifest: map[string]any{}}})
if err == nil {
err = KeepRevision(ctx, ix.Revisions, rev, objects)
}
if err != nil {
t.Fatal(err)
}
}
keep(1, "fp1")
if held, err := ix.SeedEntryHeld(ctx, "avahi", "fp1"); err != nil || !held {
t.Errorf("the entry at its fingerprint: %v, %v", held, err)
}
if in, err := ix.ModuleInNewestView(ctx, "avahi"); err != nil || !in {
t.Errorf("the module in the view: %v, %v", in, err)
}
if in, _ := ix.ModuleInNewestView(ctx, "gone"); in {
t.Error("a module the view does not hold is in it")
}
keep(2, "fp2")
if held, _ := ix.SeedEntryHeld(ctx, "avahi", "fp1"); held {
t.Error("a candidate the newest revision replaced is still held")
}
})
t.Run("a branch is watched while a registration names it", func(t *testing.T) {
g := newRegRig()
ix := &Indexer{Module: testSelf, Registry: g.r}
raw, _ := json.Marshal(meshcatalog.Registration{Module: "avahi", Branches: []string{"main", "feat"}})
if err := g.r.Registrations.Create(ctx, "avahi", raw); err != nil {
t.Fatal(err)
}
if w, err := ix.BranchWatched(ctx, TrunkBranch); err != nil || !w {
t.Errorf("the trunk: %v, %v", w, err)
}
if w, _ := ix.BranchWatched(ctx, "feat"); !w {
t.Error("a branch a registration names is not watched")
}
if w, _ := ix.BranchWatched(ctx, "other"); w {
t.Error("a branch no registration names is watched")
}
})
}
// A-190: a call that ends with its ask closed is not said unanswered: no finding, and the seed goes on.
func TestAClosedAskIsNotUnanswered(t *testing.T) {
ctx := context.Background()
closed := fmt.Errorf("steps: %w", ErrAskClosed)
ix := &Indexer{Module: testSelf, Findings: newFindings(), Heard: newMem(), Revisions: newMemObjects(1 << 20), Versions: newMem()}
rev, objects, _ := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 1, Kind: "trunk"}, map[string]meshcatalog.CatalogEntry{"avahi": {Module: "avahi", Fp: "fp", Manifest: map[string]any{},
Artifacts: []meshcatalog.Artifact{{Ref: "avahi:program", Language: "go"}}}})
if err := KeepRevision(ctx, ix.Revisions, rev, objects); err != nil {
t.Fatal(err)
}
defs := map[string]seatdef.Definition{"node-build-go": {Acts: []seatdef.ActingRule{{Step: seatdef.StepBuild, On: "go"}}}}
if _, err := ix.SeedModulesFrom(ctx, defs, func(context.Context, string, nodebuildgo.StepsInput) (nodebuildgo.StepsAnswer, error) {
return nodebuildgo.StepsAnswer{}, closed
}); err != nil || len(ix.stepsSince) != 0 {
t.Errorf("a closed steps ask counted unanswered: %v %v", err, ix.stepsSince)
}
}