Refuse a declaring module's mergeable file that names no keys (hq issue 574, ADR 0326 §3)
mesh/merge-gate head db0cb1e15e39 merged into trunk 56d6313262e8 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head db0cb1e15e39 merged into trunk 56d6313262e8 — fail: its merge-check.sh failed: --- FAIL: TestTheInstallersFirstUserListIsWhatTheContro…
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate head db0cb1e15e39 merged into trunk 56d6313262e8 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head db0cb1e15e39 merged into trunk 56d6313262e8 — fail: its merge-check.sh failed: --- FAIL: TestTheInstallersFirstUserListIsWhatTheContro…
mesh/delivery superseded: a newer head of the same pull request
A module that declares a setting and owns a mergeable file naming no keys still let every key reach that file. The refusal was held back in #272 because betterbird was one; mesh-catalog #252 named its keys, and every module in mesh-catalog and mesh-media-catalog main now passes, so the module check and registration refuse it again. A stored definition is still composed as it is, never left out of a machine.
This commit is contained in:
@@ -70,10 +70,23 @@ func namesItsKeys(m Manifest) bool {
|
||||
// reads itself, one the file keeps for itself, or one mergeable file naming its keys beside another
|
||||
// that names none.
|
||||
func TakenSettingsProblems(m Manifest) []string {
|
||||
// Not yet here: refusing a module that declares a setting and owns a mergeable file naming no keys
|
||||
// (ADR 0326 §3). betterbird is one, and the catalogue cannot name its keys before this controller
|
||||
// runs, so that refusal follows once the catalogue does (novox/hq issue 574).
|
||||
return takenSettingsProblems(m)
|
||||
problems := takenSettingsProblems(m)
|
||||
// **A module that declares a setting names the keys of every mergeable file** (ADR 0326 §3, ADR
|
||||
// 0164 §11 and §15; novox/hq issue 574): only a module that declares none keeps today's form. Said
|
||||
// where a definition is checked and registered, never where a stored one is composed: a definition
|
||||
// stored before this rule is brought into the form by its next change, not left out of a machine
|
||||
// meanwhile.
|
||||
if len(m.Settings) > 0 {
|
||||
for _, r := range m.Resources {
|
||||
how, _ := r["merge"].(string)
|
||||
if _, said := r[TakesSettingsField]; how != "" && !said {
|
||||
problems = append(problems, fmt.Sprintf("%s declares settings, and its mergeable %v names no %s: "+
|
||||
"a module that declares a setting names the keys each mergeable file takes, an empty list "+
|
||||
"for none (novox/hq ADR 0326 §3, ADR 0164 §11)", m.Module, r["id"], TakesSettingsField))
|
||||
}
|
||||
}
|
||||
}
|
||||
return problems
|
||||
}
|
||||
|
||||
// takenSettingsProblems is every rule of ADR 0326 §2 and §4, judged where a definition is checked and
|
||||
|
||||
@@ -194,3 +194,29 @@ func containsText(list []string, text string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestAModuleThatDeclaresASettingNamesItsFilesKeys(t *testing.T) {
|
||||
// ADR 0326 §3, ADR 0164 §15, novox/hq issue 574: only a module that declares no settings keeps
|
||||
// today's form. One that declares a preference and owns a silent mergeable file is refused where it
|
||||
// is checked — and not where a stored definition is composed, so a machine does not lose it before
|
||||
// its next change.
|
||||
m := twoFiles(nil, nil)
|
||||
m.Settings = map[string]SettingDeclaration{"site-name": {Kind: KindPreference, Default: "Search", Why: "a name"}}
|
||||
problems := TakenSettingsProblems(m)
|
||||
if len(problems) != 2 || !containsText(problems, "app names no takes-settings") ||
|
||||
!containsText(problems, "sidecar names no takes-settings") {
|
||||
t.Errorf("problems: %v", problems)
|
||||
}
|
||||
if err := JudgeSettings(m, nil, false); err != nil {
|
||||
t.Errorf("a stored definition is composed as before, and was refused: %v", err)
|
||||
}
|
||||
m = twoFiles([]any{"server"}, []any{})
|
||||
m.Settings = map[string]SettingDeclaration{"site-name": {Kind: KindPreference, Default: "Search", Why: "a name"}}
|
||||
if problems := TakenSettingsProblems(m); len(problems) != 0 {
|
||||
t.Errorf("every mergeable file names its keys, and was refused: %v", problems)
|
||||
}
|
||||
// And a module that declares none keeps today's form, silent files and all.
|
||||
if problems := TakenSettingsProblems(twoFiles(nil, nil)); len(problems) != 0 {
|
||||
t.Errorf("a module declaring no setting was refused: %v", problems)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user