selfcompose: the running statement's manifest is the second source of the one place; a composition answers only whether the build keeps data (A-484a)

Builds: design 47 G A-484a, A-484
This commit is contained in:
2026-11-18 00:49:53 +01:00
parent 7b6468e2bb
commit 91dc064f92
4 changed files with 41 additions and 17 deletions
+15 -8
View File
@@ -23,15 +23,17 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) {
composition string // the composition this node runs: its build ("running", "other") or none
data bool
trunk bool
statement bool // the running event names a manifest this node holds (A-484a)
wantSource string
wantKnown bool
}{
{"its entry answers first", "running", "running", false, true, SourceEntry, true},
{"the entry of the composition's build is the running build's", "other", "other", true, true, SourceEntry, true},
{"a composition with no manifest keeps the trunk's manifest and its data", "", "running", true, true, SourceTrunk, true},
{"a composition and no trunk answer: its build and its data alone", "", "running", true, false, SourceComposition, false},
{"the trunk alone", "", "", false, true, SourceTrunk, true},
{"none answers", "", "", false, false, "", false},
{"its entry answers first", "running", "running", false, true, false, SourceEntry, true},
{"the entry of the composition's build is the running build's", "other", "other", true, true, false, SourceEntry, true},
{"a composition with no manifest keeps the trunk's manifest and its data", "", "running", true, true, false, SourceTrunk, true},
{"a composition and no trunk answer: its build and its data alone", "", "running", true, false, false, SourceComposition, false},
{"the trunk alone", "", "", false, true, false, SourceTrunk, true},
{"its running statement's manifest comes before the trunk's", "", "running", true, true, true, SourceStatement, true},
{"none answers", "", "", false, false, false, "", false},
} {
t.Run(tc.name, func(t *testing.T) {
env := newFakeBus().env()
@@ -48,6 +50,11 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) {
c.mu.Lock()
c.assignments["n1"] = meshmoduleassigner.Assignments{Node: "n1", Modules: []meshmoduleassigner.PlacedModule{{Module: "xorg"}}}
c.heard = map[string]map[string]heardRun{"n1": {"xorg": {fingerprint: running}}}
if tc.statement {
digest := "sha256:" + strings.Repeat("9", 64)
c.heard["n1"]["xorg"] = heardRun{fingerprint: running, manifest: digest}
c.manifests[digest] = []byte(body)
}
if tc.trunk {
var man map[string]any
_ = json.Unmarshal([]byte(body), &man)
@@ -65,10 +72,10 @@ func TestTheManifestOfTheRunningBuildIsReadInOnePlace(t *testing.T) {
if tc.wantSource != "" && (len(said) != 1 || again.Said != "" || !strings.Contains(said[0], tc.wantSource)) {
t.Errorf("said %q (and %q again), want its source once", said, again.Said)
}
if tc.composition != "" && a.Data != tc.data && a.Source != SourceEntry {
if tc.composition != "" && a.Data != tc.data && a.Source != SourceEntry && a.Source != SourceStatement {
t.Errorf("the composition's data = %v, want %v", a.Data, tc.data)
}
if !tc.wantKnown && !strings.Contains(a.Why, SourceEntry) || !tc.wantKnown && !strings.Contains(a.Why, SourceComposition) || !tc.wantKnown && !strings.Contains(a.Why, SourceTrunk) {
if !tc.wantKnown && !strings.Contains(a.Why, SourceEntry) || !tc.wantKnown && !strings.Contains(a.Why, SourceStatement) || !tc.wantKnown && !strings.Contains(a.Why, SourceTrunk) {
t.Errorf("the words of an answer that reads no manifest are %q, want the three sources named", a.Why)
}
})