Indexer's tests compute with its own fingerprint package
So mesh-sdk can drop SourceFingerprint2, NamedTree and NoPackageVersion (SDK1) without breaking them. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -7,12 +7,14 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
|
||||
"mesh-delivery-indexer/internal/fingerprint"
|
||||
)
|
||||
|
||||
// aBase is the new-form fingerprint of a base module, the one SourceFingerprint2 gives for the inputs of avahi at a tree.
|
||||
// aBase is the new-form fingerprint of a base module, the one fingerprint.Of gives for the inputs of avahi at a tree.
|
||||
func aBase(t *testing.T) string {
|
||||
t.Helper()
|
||||
fp, none := delivery.SourceFingerprint2(delivery.SourceInputs2{Module: "mesh-tools", Tree: "basetree"})
|
||||
fp, none := fingerprint.Of(fingerprint.Inputs{Module: "mesh-tools", Tree: "basetree"})
|
||||
if none != "" {
|
||||
t.Fatal(none)
|
||||
}
|
||||
@@ -53,7 +55,7 @@ func TestAnArtifactWhoseLockFileTheMergeDidNotCarryHasNoLocksEntry(t *testing.T)
|
||||
t.Errorf("languages = %v, want tools: go (the toolchain still applies)", in.Languages)
|
||||
}
|
||||
// With the toolchain known, mesh-sdk gives such inputs a src2: value, never 'no lock'.
|
||||
if fp, none := delivery.SourceFingerprint2(in.Kept.With("avahi", map[string]delivery.Toolchain2{"tools": {Language: "go", Version: "1.25.0", Recipe: "1"}})); fp == "" || none != "" {
|
||||
if fp, none := fingerprint.Of(inputsFrom("avahi", *in.Kept, map[string]delivery.Toolchain2{"tools": {Language: "go", Version: "1.25.0", Recipe: "1"}})); fp == "" || none != "" {
|
||||
t.Errorf("fingerprint = %q none %q, want a value", fp, none)
|
||||
}
|
||||
// A TypeScript bundle without package-lock.json (go.sum of another language does not count).
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
|
||||
"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
|
||||
@@ -29,7 +31,7 @@ func TestAModuleNamingItsPathsTakesItsTreeFromThemAndKeepsTheirObjects(t *testin
|
||||
if !ok || m.Inputs2 == nil {
|
||||
t.Fatalf("module = %+v (%v)", m, ok)
|
||||
}
|
||||
want, err := delivery.NamedTree(delivery.ManifestDigest([]byte(raw)), sdkObjects)
|
||||
want, err := fingerprint.NamedTree(delivery.ManifestDigest([]byte(raw)), sdkObjects)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -76,7 +78,7 @@ func TestACandidatesModuleTakesTheNamedPathsObjectsFromThePreview(t *testing.T)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
named, _ := delivery.NamedTree(digest, sdkObjects)
|
||||
named, _ := fingerprint.NamedTree(digest, sdkObjects)
|
||||
with := delivery.Preview{Modules: map[string]delivery.PreviewModule{".": {Tree: named, Manifest: digest, Paths: sdkObjects}}}
|
||||
without := delivery.Preview{Modules: map[string]delivery.PreviewModule{".": {Tree: "roottree", Manifest: digest}}}
|
||||
if got := ix.candidateModule(context.Background(), "mesh-sdk", ".", without, nil, nil); !strings.Contains(got.None2, "named paths") {
|
||||
@@ -112,7 +114,7 @@ func TestTheIndexerAsksTheForgeForTheNamedPathsObjectsOfAMerge(t *testing.T) { /
|
||||
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, _ := delivery.NamedTree(delivery.ManifestDigest([]byte(raw)), sdkObjects)
|
||||
want, _ := fingerprint.NamedTree(delivery.ManifestDigest([]byte(raw)), sdkObjects)
|
||||
if m.Inputs2 == nil || m.Inputs2.Tree != want {
|
||||
t.Errorf("module = %+v, want the named tree %s", m, want)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
|
||||
"mesh-delivery-indexer/internal/fingerprint"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -124,7 +126,7 @@ func TestACandidatesModuleGetsTheFingerprintATrunkModuleOfTheSameTreeHas(t *test
|
||||
pv.Modules["modules/avahi"] = m
|
||||
pv.Merge = "8888888888888888888888888888888888888888"
|
||||
applyPreview(t, ix, pv)
|
||||
if got := fpOf(t, cands); got.FP2 != "" || got.None2 != delivery.NoPackageVersion+sdk {
|
||||
if got := fpOf(t, cands); got.FP2 != "" || got.None2 != fingerprint.NoPackageVersion+sdk {
|
||||
t.Errorf("a package nothing published: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ type RepoRead struct {
|
||||
Trees map[string]string
|
||||
Manifests map[string]string
|
||||
Locks map[string]map[string]string
|
||||
// Packages are the mesh packages each directory's go.sum names (delivery.MeshPackagesOf, novox/hq ADR 0573 §2).
|
||||
// Packages are the mesh packages each directory's go.sum names (fingerprint.MeshPackagesOf, novox/hq ADR 0573 §2).
|
||||
Packages map[string][]string
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/delivery"
|
||||
|
||||
"mesh-delivery-indexer/internal/fingerprint"
|
||||
)
|
||||
|
||||
// The fixtures here are mesh-catalog a67f0196's manifests (testdata, captured from that commit) with the module renamed (and,
|
||||
@@ -148,16 +150,16 @@ func builderModules(t *testing.T) []mod {
|
||||
}
|
||||
}
|
||||
|
||||
func goInputs(t *testing.T, ix *Indexer, mods *memStore, module, builder string, bases ...string) delivery.SourceInputs2 {
|
||||
func goInputs(t *testing.T, ix *Indexer, mods *memStore, module, builder string, bases ...string) fingerprint.Inputs {
|
||||
t.Helper()
|
||||
return delivery.SourceInputs2{Module: module, Tree: "tree-" + module, Builder: builder, Bases: bases,
|
||||
return fingerprint.Inputs{Module: module, Tree: "tree-" + module, Builder: builder, Bases: bases,
|
||||
Locks: map[string]string{"tools": avahiGoSum},
|
||||
Toolchains: map[string]delivery.Toolchain2{"tools": {Language: "go", Version: "go1.27.1", Recipe: "1"}}}
|
||||
}
|
||||
|
||||
func fp2(t *testing.T, in delivery.SourceInputs2) string {
|
||||
func fp2(t *testing.T, in fingerprint.Inputs) string {
|
||||
t.Helper()
|
||||
fp, none := delivery.SourceFingerprint2(in)
|
||||
fp, none := fingerprint.Of(in)
|
||||
if none != "" {
|
||||
t.Fatal(none)
|
||||
}
|
||||
@@ -303,7 +305,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
||||
if err := ix.Apply(context.Background(), uses); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if u, _ := moduleOf(t, mods, "avahi"); u.FP2 != "" || u.None2 != delivery.NoPackageVersion+sdk {
|
||||
if u, _ := moduleOf(t, mods, "avahi"); u.FP2 != "" || u.None2 != fingerprint.NoPackageVersion+sdk {
|
||||
t.Errorf("no published mesh-sdk: fp2 %q none2 %q", u.FP2, u.None2)
|
||||
}
|
||||
tools, _ := moduleOf(t, mods, "mesh-tools")
|
||||
|
||||
Reference in New Issue
Block a user