diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index ec6a1a964..ea89b9c01 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -4293,7 +4293,7 @@ func caseOnlyAClaimantDeclaresASeatsPath(t *testing.T) { uplink := catalogue.Manifest{Module: "uplink", Version: "1", Claims: []catalogue.Claim{{Name: "node-uplink", Scope: catalogue.ScopeNode}}, Facts: map[string]catalogue.RosterFile{"resolvers": {Path: catalogue.ResolverFile, Template: "nameserver 10.42.0.1\n"}}} resolver := localResolver() - resolver.Claims[0].Serves = []string{"routes", "route", "unroute"} + resolver.Claims[0].Serves = seatVerbs(catalogue.ResolverSeat) if got := CatalogueProblems(catalogue.Shelf{"uplink": uplink, resolver.Module: resolver}); len(got) != 0 { t.Errorf("the uplink's holder and the resolver's declaring the resolver file were refused: %v", got) } @@ -4409,7 +4409,7 @@ func caseReplay412(t *testing.T) { t.Fatal("no node-hostname seat") } holder := catalogue.Manifest{Module: "names", Version: "1", Claims: []catalogue.Claim{{Name: "node-hostname", Scope: catalogue.ScopeNode, - Serves: []string{"entries", "add", "remove"}}}} + Serves: seatVerbs("node-hostname")}}} err := catalogue.CanHold(holder, seat) if err == nil { t.Fatal("a holder of node-hostname declaring neither /etc/hosts nor /etc/hostname was accepted") @@ -4959,7 +4959,7 @@ func caseTheMeshsOwnSeatsAreStillClaimable(t *testing.T) { // It delivers the bus, so its holder provides the bus — the rule this check now enforces. m := catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus", Scope: catalogue.ScopeMesh, Credential: &catalogue.OfferCredential{Form: catalogue.CredentialFormNone}}}, - Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Serves: []string{"snapshot-get", "snapshot-restore", "snapshot-restore-cancel", "snapshot-remove"}}}} + Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Serves: seatVerbs("mesh-broker")}}} if got := problemsFor(t, catalogue.Shelf{"nats": m}); got != "" { t.Fatalf("a mesh seat was refused by the derived check: %s", got) } @@ -5308,7 +5308,7 @@ func caseTheUplinkIsANodeSeatThatDeliversNothing(t *testing.T) { if !known { t.Fatalf("the uplink is not a seat; the seats are: %s", seatNames()) } - if seat.Scope != catalogue.ScopeNode || seat.Delivers != "" || seat.Decision != "novox/hq ADR 0117" { + if seat.Scope != catalogue.ScopeNode || seat.Delivers != "" || !strings.Contains(seat.Decision, "ADR 0117") { t.Fatalf("the uplink is %+v, not a node seat delivering nothing by ADR 0117", seat) } // And a manager's module can hold it without providing anything. @@ -5640,7 +5640,7 @@ func hostnameSeat(t *testing.T) catalogue.Seat { func hostnameHolder(resources ...map[string]any) catalogue.Manifest { return catalogue.Manifest{Module: "names", Version: "1", Claims: []catalogue.Claim{{Name: "node-hostname", Scope: catalogue.ScopeNode, - Serves: []string{"entries", "add", "remove"}}}, Resources: resources} + Serves: seatVerbs("node-hostname")}}, Resources: resources} } func mustParse(t *testing.T, raw string) catalogue.Manifest { @@ -6248,6 +6248,20 @@ const mailStream = `[{"name":"mail","events":["mail.*.message.added","mail.*.mes // localResolver is a stand-in holder: it claims the seat and renders the resolver file naming the // machine's own address. What is under test is the controller's rule, not the catalogue's module. +// seatVerbs are the verbs the seat's definition declares, as a holder's claim names them: a verb added to a seat (met at +// mesh-networking a49d6d0, node-resolver's uplink-names) never breaks a test that lists them by hand. +func seatVerbs(seat string) []string { + def, ok := catalogue.SeatNamed(seat) + if !ok { + panic(seat + " is not a seat; the seats are: " + seatNames()) + } + var verbs []string + for _, v := range def.Serves { + verbs = append(verbs, v.Name) + } + return verbs +} + func localResolver() catalogue.Manifest { return catalogue.Manifest{Module: "local-resolver", Version: "1", Claims: []catalogue.Claim{{Name: catalogue.ResolverSeat, Scope: catalogue.ScopeNode}},