selfcompose: a module that runs with no entry of its wanted or running build counts what its trunk build provides (A-480a)

Builds: design 47 G A-480a (G-22-lead-answers-2.md)
This commit is contained in:
2026-11-17 23:09:15 +01:00
parent e7803f8943
commit 7bfeb466bf
2 changed files with 69 additions and 4 deletions
+18 -4
View File
@@ -274,15 +274,25 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
holds bool
laid bool
wantFp string
trunk bool // A-480a: the catalog half's trunk build of the module has an entry (the newest build has none)
}{
{"runs, newest entry held", true, newest, true, true, old},
{"not running here", false, newest, true, false, old},
{"names no newer build", true, "", false, false, old},
{"newest entry not held", true, newest, false, false, old},
{"runs, newest entry held", true, newest, true, true, old, false},
{"not running here", false, newest, true, false, old, false},
{"names no newer build", true, "", false, false, old, false},
{"newest entry not held", true, newest, false, false, old, false},
{"runs, no newest build, trunk entry held (A-480a)", true, "", false, true, old, true},
{"not running here, trunk entry held (A-480a)", false, "", false, false, old, true},
} {
t.Run(tc.name, func(t *testing.T) {
env := newFakeBus().env()
env.Node = "n1"
trunkFp := meshcatalogclient.SourcePrefix2 + strings.Repeat("4", 64)
env.Entry = EntryCall(func(_ context.Context, _, verb string, _ any) (json.RawMessage, error) {
if verb == meshcatalog.VerbModule && tc.trunk {
return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Fp: trunkFp}})
}
return nil, errors.New("not held")
})
c := New(env)
c.mu.Lock()
c.wants["postgres"] = meshwants.WantsByWantNodeModuleValue{Fp: old, Newest: tc.newest}
@@ -294,6 +304,10 @@ func runningModuleWithoutEntryStandsAsTheNewestBuild(t *testing.T) {
if tc.holds {
c.holdEntry(t, "postgres", newest, body)
}
if tc.trunk {
c.holdEntry(t, "postgres", trunkFp, body)
}
c.askTrunkBuilds()()
if got := c.wantedBuilds()[newest]; tc.newest != "" && got {
t.Errorf("the newest build is named by a want, want only asked")
}