package catalogue import ( "strings" "testing" ) // Defends novox/hq ADR 0287 (issue 412): a seat names the paths its holder owns, a claim without them is // refused, and only a claimant declares a seat's path. // The starting set, exactly: node-hostname names /etc/hosts and /etc/hostname, node-uplink the resolver // file stepping back for node-resolver, node-resolver the resolver file, and every other seat names none. func TestTheSeatsThatNamePathsAreTheStartingSet(t *testing.T) { want := map[string]string{ "node-hostname": "/etc/hosts /etc/hostname", "node-uplink": "/etc/resolv.conf>node-resolver", ResolverSeat: "/etc/resolv.conf", } for _, s := range DefaultSeats() { var got []string for _, p := range s.Paths { if p.StepsBackFor != "" { got = append(got, p.Path+">"+p.StepsBackFor) } else { got = append(got, p.Path) } } if strings.Join(got, " ") != want[s.Name] { t.Errorf("%s names %v; ADR 0287 gives it %q", s.Name, got, want[s.Name]) } } } func hostnameSeat(t *testing.T) Seat { t.Helper() s, ok := SeatNamed("node-hostname") if !ok { t.Fatal("no node-hostname seat") } return s } func hostnameHolder(resources ...map[string]any) Manifest { return Manifest{Module: "names", Version: "1", Claims: []Claim{{Name: "node-hostname", Scope: ScopeNode, Serves: []string{"entries", "add", "remove"}}}, Resources: resources} }