A branch's revision number is the indexer's own count (the newest + 1); the gate's source is the revision's field source, which the take-in's dedupe and source-to-take read. A catalog revision carries its call (the seat mesh-catalog's CatalogRevision and catalog-revision gain call, regenerated by seatgen). A re-pin on a module's release runs on every watched branch holding a module that names its package (the first on the modules state, another on its newest revision's picture), and keeps, where a fingerprint moved, the branch's next revision of the same source with the call 'release of <module> <version>' and the moved modules as its movers, pinned for the release's pipeline, and says catalog-revision; no take-in.taken. Builds: design 47 H S11, S12, S13, S14 (H-pins-spec-and-gaps item 1), H-A-211, H-A-212, H-A-213 (1)-(4: the pin of every revision a pipeline runs on), H-A-147
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)
|
|
}
|
|
}
|