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
114 lines
5.5 KiB
Go
114 lines
5.5 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
|
|
"mesh-delivery-indexer/internal/fingerprint"
|
|
)
|
|
|
|
// ADR 0499 clauses 2 and 3 (I7): a module whose every artifact names its paths takes its tree input from them, by mesh-sdk's
|
|
// one function, and keeps their objects, so a computation from kept inputs gives the merge's value. The manifest is
|
|
// mesh-sdk's module.json at 9cb4d59 (its lib names src, test, package.json, package-lock.json and tsconfig.json).
|
|
|
|
var sdkObjects = map[string]string{"src": "1111111111111111111111111111111111111111", "test": "2222222222222222222222222222222222222222",
|
|
"package.json": "3333333333333333333333333333333333333333", "package-lock.json": "4444444444444444444444444444444444444444", "tsconfig.json": "5555555555555555555555555555555555555555"}
|
|
|
|
func TestAModuleNamingItsPathsTakesItsTreeFromThemAndKeepsTheirObjects(t *testing.T) { // I7, ADR 0499 clause 2
|
|
ix, mods, _ := manifestsIndexer(t)
|
|
raw := fixture(t, "sdk-9cb4d59-mesh-sdk")
|
|
f := withManifests(mergedMsg("novox/mesh-sdk", map[string]string{"": "roottree"}), map[string]string{"": raw}, map[string]map[string]string{"": {"package-lock.json": avahiGoSum}})
|
|
f.Paths = map[string]map[string]string{"": sdkObjects}
|
|
if err := ix.Apply(context.Background(), f); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, ok := moduleOf(t, mods, "mesh-sdk")
|
|
if !ok || m.Inputs2 == nil {
|
|
t.Fatalf("module = %+v (%v)", m, ok)
|
|
}
|
|
want, err := fingerprint.NamedTree(meshcatalogclient.ManifestDigest([]byte(raw)), sdkObjects)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m.Inputs2.Tree != want || !reflect.DeepEqual(m.Inputs2.Paths, sdkObjects) {
|
|
t.Errorf("inputs = %+v, want the named tree %s and the objects kept", m.Inputs2, want)
|
|
}
|
|
if got := m.Paths["lib"]; strings.Join(got, ",") != "src,test,package.json,package-lock.json,tsconfig.json" {
|
|
t.Errorf("artifact paths = %v, want lib's paths as its manifest names them", m.Paths)
|
|
}
|
|
// Recomputed from what is kept, with no merge, the module is the same (ADR 0499 clause 2).
|
|
before := string(mods.vals["mesh-sdk"])
|
|
if err := ix.Recompute(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if string(mods.vals["mesh-sdk"]) != before {
|
|
t.Errorf("a recompute changed the module: %s, was %s", mods.vals["mesh-sdk"], before)
|
|
}
|
|
}
|
|
|
|
func TestAMessageWithoutTheNamedPathsObjectsGivesTheModuleNoneNamingThem(t *testing.T) { // I7, ADR 0499 clause 3
|
|
ix, mods, _ := manifestsIndexer(t)
|
|
raw := fixture(t, "sdk-9cb4d59-mesh-sdk")
|
|
f := withManifests(mergedMsg("novox/mesh-sdk", map[string]string{"": "roottree"}), map[string]string{"": raw}, nil)
|
|
if err := ix.Apply(context.Background(), f); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, _ := moduleOf(t, mods, "mesh-sdk")
|
|
if m.Fp2 != "" || !strings.Contains(m.None2, "named paths") || !strings.Contains(m.None2, "tsconfig.json") {
|
|
t.Errorf("module = %+v, want none naming the paths the message did not carry", m)
|
|
}
|
|
}
|
|
|
|
func TestAModuleNamingNoPathsKeepsItsDirectorysTree(t *testing.T) { // I7, ADR 0499 clause 2: every other module is unchanged
|
|
in := inputsOfNamed("avahi", catalogueManifest(t, "avahi"), "avahitree", map[string]string{"go.sum": avahiGoSum}, map[string]string{"x": "1111111111111111111111111111111111111111"}, nil, noBases)
|
|
if in.Kept == nil || in.Kept.Tree != "avahitree" || in.Kept.Paths != nil {
|
|
t.Errorf("inputs = %+v, want the directory's tree and no paths", in.Kept)
|
|
}
|
|
}
|
|
|
|
func TestTheIndexerAsksTheForgeForTheNamedPathsObjectsOfAMerge(t *testing.T) { // I6 as the lead has it: the indexer is the one reader of paths
|
|
ix, mods, _ := manifestsIndexer(t)
|
|
type ask struct {
|
|
repository, sha string
|
|
paths map[string][]string
|
|
}
|
|
var asked []ask
|
|
ix.Named = func(_ context.Context, repository, sha string, paths map[string][]string) (map[string]map[string]string, error) {
|
|
asked = append(asked, ask{repository, sha, paths})
|
|
return map[string]map[string]string{"": sdkObjects}, nil
|
|
}
|
|
raw := fixture(t, "sdk-9cb4d59-mesh-sdk")
|
|
f := withManifests(mergedMsg("novox/mesh-sdk", map[string]string{"": "roottree", "modules/a": "t"}), map[string]string{"": raw, "modules/a": `{"module":"a","version":"1.0"}`}, nil)
|
|
if err := ix.Apply(context.Background(), f); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(asked) != 1 || asked[0].repository != "novox/mesh-sdk" || asked[0].sha != merge || len(asked[0].paths) != 1 ||
|
|
strings.Join(asked[0].paths[""], ",") != "package-lock.json,package.json,src,test,tsconfig.json" {
|
|
t.Fatalf("asked %+v, want the root's named paths of the merge commit, once, and nothing for a module naming none", asked)
|
|
}
|
|
m, _ := moduleOf(t, mods, "mesh-sdk")
|
|
want, _ := fingerprint.NamedTree(meshcatalogclient.ManifestDigest([]byte(raw)), sdkObjects)
|
|
if m.Inputs2 == nil || m.Inputs2.Tree != want {
|
|
t.Errorf("module = %+v, want the named tree %s", m, want)
|
|
}
|
|
}
|
|
|
|
func TestAForgeThatCannotSayTheObjectsGivesTheModuleNoneWithItsWords(t *testing.T) { // I6
|
|
ix, mods, _ := manifestsIndexer(t)
|
|
ix.Named = func(context.Context, string, string, map[string][]string) (map[string]map[string]string, error) {
|
|
return nil, errors.New("gitea: the path tsconfig.json of \"\" is not at the commit")
|
|
}
|
|
raw := fixture(t, "sdk-9cb4d59-mesh-sdk")
|
|
if err := ix.Apply(context.Background(), withManifests(mergedMsg("novox/mesh-sdk", map[string]string{"": "roottree"}), map[string]string{"": raw}, nil)); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m, _ := moduleOf(t, mods, "mesh-sdk"); m.Fp2 != "" || !strings.Contains(m.None2, "is not at the commit") {
|
|
t.Errorf("module = %+v, want none with the forge's words", m)
|
|
}
|
|
}
|