InstallationProblems judges every value the mesh acts on for a name under a public top-level domain
or a public address, with prose, the world's registries, resolvers and certificate authorities
exempt, and a name a resource means on purpose declared with its reason (names-on-purpose). Run by
module check and a catalogue-wide test, not yet at registration, while the declared list shrinks.
${setting:<key>} fills a file from the assignment's settings and is refused when nothing set it.
A build context may live on the git seat; the request carries the seat's clone base (novox/hq ADR
0112, ADR 0155, issues 122 and 134).
56 lines
2.2 KiB
Go
56 lines
2.2 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// An operator's value reaches a file from the assignment's settings, the node's layer over the
|
|
// mesh's (novox/hq ADR 0112, ADR 0155), and a value nothing set is refused by name.
|
|
func TestASettingReachesAFileFromTheLayers(t *testing.T) {
|
|
file := map[string]any{"id": "env", "type": "file", "path": "/x/mail.env",
|
|
"content": "DOMAIN=${setting:domain}\nSITENAME=${setting:sitename}\nWORKERS=${setting:workers}\n"}
|
|
layers := []Layer{
|
|
{From: "the mesh", Values: map[string]any{"domain": "example.tld", "sitename": "Mesh", "workers": float64(4)}},
|
|
{From: "this node", Values: map[string]any{"sitename": "This one"}},
|
|
}
|
|
if err := settingInto(file, layers, "mail"); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if file["content"] != "DOMAIN=example.tld\nSITENAME=This one\nWORKERS=4\n" {
|
|
t.Fatalf("filled as %q", file["content"])
|
|
}
|
|
}
|
|
|
|
func TestASettingNothingSetIsRefusedByName(t *testing.T) {
|
|
file := map[string]any{"id": "env", "type": "file", "content": "DOMAIN=${setting:domain}\n"}
|
|
err := settingInto(file, []Layer{{From: "the mesh", Values: map[string]any{"other": "x"}}}, "mail")
|
|
if err == nil {
|
|
t.Fatal("a setting nothing set was written as something")
|
|
}
|
|
for _, want := range []string{"${setting:domain}", "settings set mail", "set today: other"} {
|
|
if !strings.Contains(err.Error(), want) {
|
|
t.Fatalf("the refusal lacks %q: %v", want, err)
|
|
}
|
|
}
|
|
// Left as it was: the literal placeholder must never reach a machine.
|
|
if file["content"] != "DOMAIN=${setting:domain}\n" {
|
|
t.Fatalf("content was changed on refusal: %q", file["content"])
|
|
}
|
|
}
|
|
|
|
// A key a file asks for is a destination, so setting it is not called stray.
|
|
func TestASettingAFileAsksForIsNotStray(t *testing.T) {
|
|
m := Manifest{Module: "mail", Resources: []map[string]any{
|
|
{"id": "env", "type": "file", "content": "DOMAIN=${setting:domain}\n"},
|
|
}}
|
|
layers := []Layer{{From: "the mesh", Values: map[string]any{"domain": "example.tld", "stray": "x"}}}
|
|
unused := strings.Join(UnusedSettings(m, layers), "; ")
|
|
if strings.Contains(unused, `"domain"`) {
|
|
t.Fatalf("a key a file asks for was called stray: %s", unused)
|
|
}
|
|
if !strings.Contains(unused, `"stray"`) {
|
|
t.Fatalf("a key nothing reads was not named: %s", unused)
|
|
}
|
|
}
|