Resolution: an optional consumer of an unanswered requirement is left absent and listed (A-452, ADR 0330 §3, §7)

Builds: design 47 G A-452
This commit is contained in:
2026-11-17 00:27:47 +01:00
parent c6d893e141
commit 3bb895152f
2 changed files with 12 additions and 9 deletions
+5 -4
View File
@@ -61,6 +61,7 @@ func TestARequirementWithOneAnswerIsTakenSilently(t *testing.T) {
func TestARequirementNoOneAnswersHoldsItsConsumersAndSeveralAnswersRefuseTheNode(t *testing.T) {
optional := mod("viewer", nil, []string{"codec"}, nil)
optional.OptionalRequires = map[string]bool{"codec": true}
hard := mod("player", nil, []string{"codec"}, nil)
meshDB := mcat.Manifest{Module: "postgres", Provides: []mcat.Offer{{Name: "postgres-database", Scope: mcat.ScopeMesh}}}
for _, c := range []struct {
name string
@@ -78,8 +79,8 @@ func TestARequirementNoOneAnswersHoldsItsConsumersAndSeveralAnswersRefuseTheNode
{name: "in the whole mesh", assigned: []string{"baserow", "editor"},
shelf: shelf(meshDB, mod("baserow", nil, []string{"postgres-database"}, nil), mod("editor", nil, nil, nil)),
held: map[string]string{"baserow": `nothing in this mesh provides "postgres-database", wanted by baserow`}},
{name: "wanted only optionally", assigned: []string{"viewer", "editor"},
shelf: shelf(optional, mod("editor", nil, nil, nil)), absent: true},
{name: "wanted hard by one and optionally by another", assigned: []string{"player", "viewer"},
shelf: shelf(hard, optional), held: map[string]string{"player": `nothing provides "codec"`}, absent: true},
{name: "every module held", assigned: []string{"ca-trust"},
shelf: shelf(mod("ca-trust", nil, []string{"internal-acme-ca"}, nil)),
refused: []string{"nothing provides", "every one is held"}},
@@ -114,8 +115,8 @@ func TestARequirementNoOneAnswersHoldsItsConsumersAndSeveralAnswersRefuseTheNode
t.Errorf("%s is held with %q, want %q", m, held[m], w)
}
}
if c.absent && (len(held) != 0 || len(got.Absent) == 0) {
t.Errorf("an optional requirement was held or not left absent: held %v absent %v", held, got.Absent)
if _, heldToo := held["viewer"]; c.absent && (heldToo || len(got.Absent) != 1 || got.Absent[0] != (mcat.Absent{Consumer: "viewer", Requirement: "codec"})) {
t.Errorf("the optional consumer was held or not listed absent: held %v absent %v", held, got.Absent)
}
if len(got.Modules) != len(c.assigned) {
t.Errorf("the node does not keep every module of its set: %v", names(got))