package main import ( "os" "path/filepath" "strings" "testing" ) // No manifest invokes the controller's hand-act verbs but a named fallback; a named fallback no longer invoked is // refused (novox/hq ADR 0565 ยง11's catalog test). func TestFindings(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","invokes":["seat:mesh-hand-acts.hand-act"]}`}, ""}, {"an unnamed call", map[string]string{"modules/a/module.json": `{"module":"a","invokes":["seat:mesh-controller.warranted"]}`}, "a invokes seat:mesh-controller.warranted"}, {"a named fallback, and the controller's own", map[string]string{ "modules/a/module.json": `{"module":"a","invokes":["seat:mesh-controller.drill"]}`, "modules/mesh-controller/module.json": `{"module":"mesh-controller","invokes":["seat:mesh-controller.hand-act"]}`, Allowed: "# why\na drill fallback until the lease write\n"}, ""}, {"a fallback no longer invoked", map[string]string{Allowed: "gone hand-act fallback\n"}, `names "gone hand-act"`}, {"another verb of the controller", map[string]string{"modules/a/module.json": `{"module":"a","invokes":["seat:mesh-controller.conditions"]}`}, ""}, } { 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 run of this check over the real tree. func TestTheCatalogRecordsOnlyThroughTheSeat(t *testing.T) { got, err := Findings(filepath.Join("..", "..")) if err != nil { t.Fatal(err) } for _, f := range got { t.Error(f) } }