TakeInSource takes a gate's source-moved in: the trees of each repository it moves at the named commit through the seat git, the fingerprints of the modules registered for it, the movers against the branch's newest catalog revision, and one revision <escaped branch>.<source> for every branch, the trunk included, numbered by the source and written once by read before write. The revision carries its movers, and a redelivery whose revision is kept says take-in.taken again from them, recomputing nothing (H-A-92). It is pinned for the take-in's pipeline as pipeline.<branch>.<source> in the same write when it has a mover, none for a take-in with no mover. take-in.taken carries branch, source, revision, call and the movers' entries alone, under a duplicate id of its branch and source (H-A-31). A source-moved with no call is refused as the old form (§765). Only a take-in keeps a catalog revision (H-A-49): the recompute, the build ends' imports and the start's reconcile keep none, and KeepView, keepEntries, keepTrunkRevision and PinPipelines go. Another branch than the first is taken in on its newest revision's view. Builds: design 47 H §743, §749 (the pin in the take-in's write), §765 (the old form); H-A-31, H-A-32, H-A-49, H-A-92 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
59 lines
2.9 KiB
Go
59 lines
2.9 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
|
)
|
|
|
|
// Design 47 G §675: the entry kept for a build-input fingerprint is found by it, through the key entry-index holds for the
|
|
// digest of its object; a fingerprint no entry carries is answered with an error naming it.
|
|
func TestEntryFindsAnEntryByItsFingerprint(t *testing.T) {
|
|
ctx := context.Background()
|
|
fp := "src2:" + strings.Repeat("b", 64)
|
|
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), EntryIndex: newMem(), Now: func() time.Time { return time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC) }}
|
|
entries := map[string]meshcatalog.CatalogEntry{
|
|
"avahi": {Module: "avahi", Repository: "novox/r", Commit: "c", Fp: fp, Manifest: map[string]any{}},
|
|
"none": {Module: "none", Repository: "novox/r", Commit: "c", Manifest: map[string]any{}},
|
|
}
|
|
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 1, Kind: "trunk"}, entries)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := ix.indexEntries(ctx, rev, entries); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := KeepRevision(ctx, ix.Revisions, rev, objects); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, err := Entry(ctx, ix.Revisions, ix.EntryIndex, meshcatalog.EntryInput{Fingerprint: fp}); err != nil || got.Entry.Module != "avahi" {
|
|
t.Fatalf("entry of %s: %+v %v, want avahi's", fp, got, err)
|
|
}
|
|
if keys, _ := ix.EntryIndex.Keys(ctx); len(keys) != 1 {
|
|
t.Errorf("entry-index holds %v, want the one key of the entry that has a fingerprint", keys)
|
|
}
|
|
if _, err := Entry(ctx, ix.Revisions, ix.EntryIndex, meshcatalog.EntryInput{Fingerprint: "src2:" + strings.Repeat("c", 64)}); err == nil || !strings.Contains(err.Error(), "no entry of fingerprint") {
|
|
t.Errorf("an unknown fingerprint: %v, want an error naming it", err)
|
|
}
|
|
if _, err := Entry(ctx, ix.Revisions, ix.EntryIndex, meshcatalog.EntryInput{}); err == nil {
|
|
t.Errorf("no fingerprint was answered")
|
|
}
|
|
}
|
|
|
|
// Design 47 G §675: the revision the indexer keeps writes entry-index for every entry that has a fingerprint, before it keeps
|
|
// the revision, so entry finds the entry as soon as the revision is kept.
|
|
func TestAKeptRevisionIndexesItsEntries(t *testing.T) {
|
|
ctx := context.Background()
|
|
fp := "src2:" + strings.Repeat("d", 64)
|
|
ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), EntryIndex: newMem(), Now: func() time.Time { return time.Date(2026, 11, 1, 3, 0, 0, 0, time.UTC) }}
|
|
if err := ix.keepBranchEntries(ctx, TrunkBranch, 1, map[string]meshcatalog.CatalogEntry{"avahi": {Module: "avahi", Repository: "novox/r", Commit: "c", Fp: fp, Manifest: map[string]any{}}}, nil); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got, err := Entry(ctx, ix.Revisions, ix.EntryIndex, meshcatalog.EntryInput{Fingerprint: fp}); err != nil || got.Entry.Module != "avahi" {
|
|
t.Fatalf("entry of %s after the revision was kept: %+v %v", fp, got, err)
|
|
}
|
|
}
|