I8: the take-in fed by the forge bridge's messages goes with B1's forgemsg: the FORGE consumer and its handlers, the group end, the pending state with its keys, claims, dry take-in and hand tools (indexer_pending, indexer_take_in_pending, indexer_drop_pending, indexer_take_in_merge, kept again for the held take-in in I5), the catch-up by comparison (kickBehind, TakeInBehind, sayUntaken, takeInHeads, kickCatchUp, CatchUp, merge-untaken), the source numbering in memory (nextSource), the source verb's follow and Src stamping on a source answer, the bridge's merged message call, the pull request candidates written from pull and open messages, the checker's previews and verdict hearing. A repository's trees at a commit are the internal whole (wholeAt), which ApplyMessage takes in; the dry indexer stays for a run on request's candidate. The manifest drops the consumes of forge.**, the checker's verdict and version-delivered, the reads of the checker's previews and the invokes of open-pulls, bridge_merged_message and mesh-delivery.source. RoomAgain says room when a take-in is held on a full store (heldFull, I5 holds it). H-A-82: the fill of delivered versions into the edges goes: HearVersionDelivered, the delivered.<module> key, the first fill's kinds 2, 4 and 6 from the placement and the stream running, and outdated's kinds 2, 4 and 6; their entries read not yet delivered. The tests of the removed paths go (index_test's candidate groups, source_test, branch_take_in_test, previews_test, candidate_manifests_test, the FORGE handle tests); the versions tests now hold kinds 2, 4 and 6 as declarations. The integration tests still drive FORGE and are rewritten in I10. Builds: design 47 H §743, §744, §764 (the indexer); H-A-48, H-A-82 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
86 lines
3.8 KiB
Go
86 lines
3.8 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
"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 fill and the seed go 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)
|
|
}
|
|
if err := ix.FillVersions(ctx, func(context.Context, string, string) (BuilderVersionsAnswer, error) {
|
|
return BuilderVersionsAnswer{}, fmt.Errorf("builder_versions: %w", ErrAskClosed)
|
|
}); errors.Is(err, ErrAskClosed) || (err != nil && strings.Contains(err.Error(), "is not answered")) {
|
|
t.Errorf("a closed versions ask is unanswered: %v", err)
|
|
}
|
|
}
|