Both reads go in R4g with build-agent. A path a key names is never overwritten, and no fingerprint changes.
68 lines
2.6 KiB
Go
68 lines
2.6 KiB
Go
package index
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// Issue 1614: a modules key written before the indexer learned paths (mesh-tools and node-tools live) gets its directory
|
|
// from the module's newest build record without waiting for a merge of its repository, once, changing no fingerprint. The
|
|
// read of the controller's build records for it goes in R4g with build-agent (the lead's decision, 2026-10-22).
|
|
|
|
func heldValue(t *testing.T, st *memStore, name, path string) {
|
|
t.Helper()
|
|
data, err := delivery.EncodeModule(delivery.Module{Repository: "novox/mesh-tools", Commit: "e0fadc43d9dda0bc24bd19bb05b021dd87da8582",
|
|
FP2: "src2:" + hex64('2'), Manifest: hex64('9'), Path: path})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
st.put(name, data)
|
|
}
|
|
|
|
func hex64(c byte) string {
|
|
b := make([]byte, 64)
|
|
for i := range b {
|
|
b[i] = c
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
func TestAnEmptyPathIsFilledOnceFromTheModulesNewestBuildRecord(t *testing.T) { // 1614
|
|
ix, mods := modulesIndexer(t,
|
|
[2]any{delivery.BuildKey("mesh-tools", "build-1"), buildRecord(t, "novox/mesh-tools", "mesh-tools", "", "2026-10-19T09:00:00Z")},
|
|
[2]any{delivery.BuildKey("node-tools", "build-2"), buildRecord(t, "novox/mesh-tools", "node-tools", "node-tools", "2026-10-19T09:00:00Z")})
|
|
heldValue(t, mods, "mesh-tools", "")
|
|
heldValue(t, mods, "node-tools", "")
|
|
before, _ := moduleOf(t, mods, "node-tools")
|
|
if err := ix.Recompute(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for name, want := range map[string]string{"mesh-tools": delivery.RootPath, "node-tools": "node-tools"} {
|
|
m, _ := moduleOf(t, mods, name)
|
|
if m.Path != want || m.FP2 != before.FP2 || m.Commit != before.Commit {
|
|
t.Errorf("%s = %+v, want path %q and nothing else changed", name, m, want)
|
|
}
|
|
}
|
|
writes := mods.writes
|
|
if err := ix.Recompute(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if mods.writes != writes {
|
|
t.Errorf("the paths were written again (%d writes, was %d): once only", mods.writes, writes)
|
|
}
|
|
}
|
|
|
|
func TestASetPathIsNeverOverwrittenByABuildRecord(t *testing.T) { // 1614
|
|
ix, mods := modulesIndexer(t, [2]any{delivery.BuildKey("node-tools", "build-2"), buildRecord(t, "novox/mesh-tools", "node-tools", "elsewhere", "2026-10-19T09:00:00Z")})
|
|
heldValue(t, mods, "node-tools", "node-tools")
|
|
writes := mods.writes
|
|
if err := ix.Recompute(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m, _ := moduleOf(t, mods, "node-tools"); m.Path != "node-tools" || mods.writes != writes {
|
|
t.Errorf("module = %+v after %d writes (was %d), want its path kept and nothing written", m, mods.writes, writes)
|
|
}
|
|
}
|