controllerdeps refuses any manifest naming the controller's seat, states or buckets, the lease and the entries once kept to its write among them, and any module file naming one of its buckets (ADR 0590 §5). The words check refuses a controller address in any text a module shows. The handacts check and noplacement's list of assignments readers are folded into it (issue 1126 B10). Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
56 lines
2.1 KiB
Go
56 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestFindingsRefuseWhatThePlacementPathLeft(t *testing.T) {
|
|
for _, row := range []struct {
|
|
name string
|
|
files map[string]string
|
|
want string // empty: clean
|
|
}{
|
|
{"clean", map[string]string{"modules/a/module.json": `{"module":"a","reads":["mesh-delivery-assigner.placement"]}`}, ""},
|
|
{"a placement directory", map[string]string{"placement/ace.json": `{}`}, "placement: the repository holds no placement"},
|
|
{"a particulars file", map[string]string{"particulars": "ace\n"}, "particulars: the repository lists no node names"},
|
|
{"a read of the indexer's placement", map[string]string{"modules/a/module.json": `{"module":"a","reads":["mesh-delivery-indexer.placement"]}`}, `a: names "mesh-delivery-indexer.placement"`},
|
|
{"a read of its candidates", map[string]string{"modules/b/module.json": `{"module":"b","reads":["mesh-delivery-indexer.placement-candidates"]}`}, "placement-candidates"},
|
|
{"its event", map[string]string{"modules/c/module.json": `{"module":"c","on":[{"event":"mesh-delivery-indexer.placement-changed"}]}`}, "placement-changed"},
|
|
{"the seat's own state is allowed", map[string]string{"modules/d/module.json": `{"module":"d","reads":["mesh-placement.placement"]}`}, ""},
|
|
} {
|
|
t.Run(row.name, func(t *testing.T) {
|
|
root := t.TempDir()
|
|
for path, text := range row.files {
|
|
p := filepath.Join(root, path)
|
|
if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(p, []byte(text), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
got, err := Findings(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if all := strings.Join(got, "\n"); (row.want == "") != (all == "") || !strings.Contains(all, row.want) {
|
|
t.Fatalf("findings = %q, want one containing %q", all, row.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// The script's run of this check over the real tree (novox/hq ADR 0529 clause 2).
|
|
func TestTheCatalogueHoldsNoPlacementOfTheRepositoryPath(t *testing.T) {
|
|
got, err := Findings(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range got {
|
|
t.Error(f)
|
|
}
|
|
}
|