package catalogue import ( "strings" "testing" ) // Replay of novox/hq issue 412 (2026-10-10): which module owns /etc/hosts was enforced only after the fact, // when two modules on one machine declared it; a module that did not claim node-hostname could declare // /etc/hosts, and a module could claim node-hostname declaring none of its paths, and nothing refused either. // Written only with what the catalogue had before its fix (mesh-controller #267): CatalogueProblems, Shelf, // SeatNamed and CanHold, so it is laid over the commit before. func TestReplay412(t *testing.T) { stranger := Manifest{Module: "stranger", Version: "1", Resources: []map[string]any{ {"id": "hosts", "type": "file", "path": "/etc/hosts", "into": "block", "content": "10.0.0.1 x\n"}}} got := strings.Join(CatalogueProblems(Shelf{"stranger": stranger}), "; ") if !strings.Contains(got, "node-hostname") { t.Errorf("a module declaring /etc/hosts without claiming node-hostname was not refused: %q", got) } seat, ok := SeatNamed("node-hostname") if !ok { t.Fatal("no node-hostname seat") } holder := Manifest{Module: "names", Version: "1", Claims: []Claim{{Name: "node-hostname", Scope: ScopeNode, Serves: []string{"entries", "add", "remove"}}}} err := CanHold(holder, seat) if err == nil { t.Fatal("a holder of node-hostname declaring neither /etc/hosts nor /etc/hostname was accepted") } for _, want := range []string{"/etc/hosts", "/etc/hostname"} { if !strings.Contains(err.Error(), want) { t.Errorf("the refusal does not name %s: %v", want, err) } } }