Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4596ec16b0 | ||
|
|
6f6327587d |
@@ -482,3 +482,29 @@ func TestAnOperatorNamedValueAFileFallsBackOnMayHaveADefault(t *testing.T) {
|
|||||||
"default": "", "runtime": true}
|
"default": "", "runtime": true}
|
||||||
refused(t, runtime, `"url"`, `a key naming "url" is the operator's value`)
|
refused(t, runtime, `"url"`, `a key naming "url" is the operator's value`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1658/AC1: a value whose only placement is ${config:key} in an item's text is placed.
|
||||||
|
func TestConfigCountsAnItemsTextAsAPlacement(t *testing.T) {
|
||||||
|
m := map[string]any{
|
||||||
|
"module": "m", "version": "1",
|
||||||
|
"config": map[string]any{
|
||||||
|
"k": map[string]any{"type": "string", "description": "a word the item says", "default": "x"},
|
||||||
|
},
|
||||||
|
"items": []any{map[string]any{"collection": "a", "content": "k = ${config:k}\n"}},
|
||||||
|
}
|
||||||
|
if _, err := parseRaw(t, m); err != nil {
|
||||||
|
t.Fatalf("a value placed only in an item's text is refused: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1658/AC2: a declared value placed nowhere, with an item that does not say it, is still refused.
|
||||||
|
func TestConfigStillRefusesAValueNoItemPlaces(t *testing.T) {
|
||||||
|
m := map[string]any{
|
||||||
|
"module": "m", "version": "1",
|
||||||
|
"config": map[string]any{
|
||||||
|
"k": map[string]any{"type": "string", "description": "a word nothing says", "default": "x"},
|
||||||
|
},
|
||||||
|
"items": []any{map[string]any{"collection": "a", "content": "k = fixed\n"}},
|
||||||
|
}
|
||||||
|
refused(t, m, `"k"`, "placed nowhere")
|
||||||
|
}
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ func settingKeysUsedBy(m Manifest) map[string]bool {
|
|||||||
return used
|
return used
|
||||||
}
|
}
|
||||||
|
|
||||||
// settingKeysAskedOutsideOwners is every key a module's files, units, contributions and served facts
|
// settingKeysAskedOutsideOwners is every key a module's files, units, items, contributions and served facts
|
||||||
// ask for: what a directory's owner may follow (OwnerSettingProblems).
|
// ask for: what a directory's owner may follow (OwnerSettingProblems).
|
||||||
func settingKeysAskedOutsideOwners(m Manifest) map[string]bool {
|
func settingKeysAskedOutsideOwners(m Manifest) map[string]bool {
|
||||||
used := map[string]bool{}
|
used := map[string]bool{}
|
||||||
@@ -354,6 +354,10 @@ func settingKeysAskedOutsideOwners(m Manifest) map[string]bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// An item's text, filled from its template (WithTemplatesFrom), places a key as a file's does (issue 1658).
|
||||||
|
for _, it := range m.Items {
|
||||||
|
note(it.Content)
|
||||||
|
}
|
||||||
inValues := func(values map[string]any) {
|
inValues := func(values map[string]any) {
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
if s, ok := v.(string); ok {
|
if s, ok := v.(string); ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user