mesh/delivery merged: source.main moved to novox/mesh-catalog@6d000647de2d
mesh/check being carried to cff1005422c1 on 6d000647de2d | from f9dcbc295723
The one bundle that did everything becomes the manager bundle, which runs long and answers the seat's ten verbs and the three acting tools, and a tools bundle of its own that answers the four reading tools and writes nothing, so they answer while the manager fails to load or stops. Both import the module's one package for the layouts of the kept data and the log entries, the key form, the entries' names and the settings with their validity; the settings file and the account with its directory stay as they are. Builds: design 39 parts §1, §2, §3, §4, §5, §6, §7, §8
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
// The module's directory, where its manifest and its files/ are.
|
|
const moduleDir = "../.."
|
|
|
|
// templateText is the text a file resource places on the machine: its template's, in the module's files/
|
|
// (novox/hq ADR 0349 §2). A resource that names no template, or a template that is not there, fails the test.
|
|
func templateText(t *testing.T, r map[string]any) string {
|
|
t.Helper()
|
|
name, _ := r["template"].(string)
|
|
if name == "" {
|
|
t.Fatalf("resource %v names no template", r["id"])
|
|
}
|
|
raw, err := os.ReadFile(filepath.Join(moduleDir, filepath.FromSlash(name)))
|
|
if err != nil {
|
|
t.Fatalf("resource %v names %s: %v", r["id"], name, err)
|
|
}
|
|
return string(raw)
|
|
}
|
|
|
|
// No file resource carries its text inline: each names its template in files/, and the build packs files/
|
|
// into the one archive the controller reads the templates back from (novox/hq ADR 0349 §2).
|
|
func TestEveryFileTakesItsTextFromATemplate(t *testing.T) {
|
|
raw, err := os.ReadFile(filepath.Join(moduleDir, "module.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var m struct {
|
|
Resources []map[string]any `json:"resources"`
|
|
Build struct {
|
|
Artifacts []map[string]any `json:"artifacts"`
|
|
} `json:"build"`
|
|
}
|
|
if err := json.Unmarshal(raw, &m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, r := range m.Resources {
|
|
if _, inline := r["content"]; inline {
|
|
t.Errorf("resource %v keeps its text inline: keep it in files/ and name it as the template", r["id"])
|
|
}
|
|
if r["type"] == "file" {
|
|
templateText(t, r)
|
|
}
|
|
}
|
|
packs := 0
|
|
for _, a := range m.Build.Artifacts {
|
|
if a["kind"] == "archive" && a["from"] == "files" {
|
|
packs++
|
|
if a["name"] != "files" {
|
|
t.Errorf("the templates archive is named %v, not files", a["name"])
|
|
}
|
|
}
|
|
}
|
|
if packs != 1 {
|
|
t.Errorf("the build packs files/ into %d archives, not one", packs)
|
|
}
|
|
}
|