mesh/merge-gate head 18221c4079d1 merged into trunk 7b2a9eae8020 — pass: builds build-agent, mesh-controller → ace, g14, novox, shanks; no bus step; every …
mesh/repo-check head 18221c4079d1 merged into trunk 7b2a9eae8020 — pass: its merge-check.sh passed
mesh/delivery delivered
ParseManifest also reads stored builds again: a build's manifest at a commit, the gate, a release, a module put back. betterbird's builds from before its accounts file named its keys would have become uncomposable there, so a send to g14 or shanks could fail and a rollback be refused. The refusal now runs in module check, module add, a build taken in, the builder and the merge gate's registration, and a file is no longer reported by both §2 and §3.
47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
)
|
|
|
|
// ADR 0326 §3 is judged where a definition is written (novox/hq issue 574): `module check`, and
|
|
// namesNoInstallation, which `module add`, a build taken in and the merge gate's registration run.
|
|
func TestWhereADefinitionIsWrittenADeclaringModuleNamesItsFilesKeys(t *testing.T) {
|
|
const silent = `{"module":"mail-client","version":"1",
|
|
"settings":{"prefs":{"kind":"preference","default":"// none","why":"its own defaults until a machine names one"}},
|
|
"resources":[
|
|
{"id":"user-js","type":"file","path":"/var/lib/mail-client/user.js","mode":"0644","content":"${setting:prefs}\n"},
|
|
{"id":"accounts","type":"file","path":"/var/lib/mail-client/accounts.json","mode":"0600","merge":"json",
|
|
"content":"{}\n"%s}]}`
|
|
dir := t.TempDir()
|
|
bad := filepath.Join(dir, "bad.json")
|
|
good := filepath.Join(dir, "good.json")
|
|
os.WriteFile(bad, []byte(strings.Replace(silent, "%s", "", 1)), 0o600)
|
|
os.WriteFile(good, []byte(strings.Replace(silent, "%s", `,"takes-settings":["accounts"]`, 1)), 0o600)
|
|
|
|
var out bytes.Buffer
|
|
if err := moduleCheck([]string{bad}, &out); err == nil ||
|
|
!strings.Contains(out.String(), "mergeable accounts names no takes-settings") {
|
|
t.Fatalf("module check passed a declaring module's silent mergeable file: %v\n%s", err, out.String())
|
|
}
|
|
out.Reset()
|
|
if err := moduleCheck([]string{good}, &out); err != nil {
|
|
t.Fatalf("the file naming its keys was refused: %v\n%s", err, out.String())
|
|
}
|
|
|
|
raw, _ := os.ReadFile(bad)
|
|
m, err := catalogue.ParseManifest(raw)
|
|
if err != nil {
|
|
t.Fatalf("reading it is not where it is judged: %v", err)
|
|
}
|
|
if err := namesNoInstallation(m); err == nil || !strings.Contains(err.Error(), "names no takes-settings") {
|
|
t.Fatalf("registration passed it: %v", err)
|
|
}
|
|
}
|