Files
mesh-host/internal/compose/seats_test.go
T

36 lines
1.2 KiB
Go

package compose
import (
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
)
// aBrokerClaiming is mesh-controller's seat_pass_test.go helper of the same name.
func aBrokerClaiming(module string) catalogue.Manifest {
return catalogue.Manifest{Module: module,
Provides: []catalogue.Offer{{Name: "mesh-bus", Scope: catalogue.ScopeMesh}},
Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Serves: brokerVerbs()}}}
}
// brokerVerbs are the verbs the seat mesh-broker promises its holder, as the contracts define them: a holder names every one
// (ADR 0132), so a fixture holder does (issue 1966 ENG-3).
func brokerVerbs() []string {
seat, _ := catalogue.SeatNamed("mesh-broker")
var out []string
for _, v := range seat.Serves {
if !v.Optional {
out = append(out, v.Name)
}
}
return out
}
// withSeat is mesh-controller's withBusSeat: a single mesh seat, mesh-broker, for the test.
func withSeat(t *testing.T) {
t.Helper()
was := catalogue.Seats()
t.Cleanup(func() { catalogue.UseSeats(was) })
catalogue.UseSeats([]catalogue.Seat{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Delivers: "mesh-bus", Decision: "test"}})
}