The controller ended by its unassignment (ADR 0590), so its seat, the grants seat's lease write and hand-back and placement's take-over from it serve nothing. The dependence check becomes strict (clause 5): a read of the lease, a claim, a require or the module itself is refused like any other declaration. held and artifacts-gone are the artifact sweep seat's (ADR 0571 §2). Issue 1126 B1, B2. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
61 lines
2.1 KiB
Go
61 lines
2.1 KiB
Go
package catalogue
|
|
|
|
import (
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The delivery seat answers "what did the mesh's checks say of this pull request?" as a verb of its own,
|
|
// `checks` (novox/hq ADR 0239): read by repository and a pull request's number or a commit.
|
|
func TestTheDeliverySeatPromisesChecks(t *testing.T) {
|
|
seat, ok := SeatNamed(DeliverySeat)
|
|
if !ok {
|
|
t.Fatal("the delivery seat is not in the set")
|
|
}
|
|
var checks *Verb
|
|
for i := range seat.Serves {
|
|
if seat.Serves[i].Name == "checks" {
|
|
checks = &seat.Serves[i]
|
|
}
|
|
}
|
|
if checks == nil {
|
|
t.Fatalf("the delivery seat promises %v and not checks", VerbNames(seat.Serves))
|
|
}
|
|
props, _ := checks.Input["properties"].(map[string]any)
|
|
for _, arg := range []string{"repository", "number", "commit"} {
|
|
if _, has := props[arg]; !has {
|
|
t.Errorf("checks takes no %q", arg)
|
|
}
|
|
}
|
|
if req, _ := checks.Input["required"].([]string); !reflect.DeepEqual(req, []string{"repository"}) {
|
|
t.Errorf("checks requires %v, wanted only the repository", req)
|
|
}
|
|
|
|
// Added after the seat's holder shipped, it is optional: the holder serving the ten verbs before it still
|
|
// holds the seat, and one serving all eleven does too — so the controller and the catalogue can move in
|
|
// either order, and no check of the catalogue fails on a module nobody touched between the two.
|
|
if !checks.Optional {
|
|
t.Fatal("checks is a condition of holding before its holder serves it")
|
|
}
|
|
var before []string
|
|
for _, v := range VerbNames(seat.Serves) {
|
|
if v != "checks" {
|
|
before = append(before, v)
|
|
}
|
|
}
|
|
m := Manifest{Module: "mesh-delivery", Claims: []Claim{{Name: DeliverySeat, Scope: ScopeMesh, Serves: before}}}
|
|
if err := CanHold(m, seat); err != nil {
|
|
t.Fatalf("a holder without checks yet: %v", err)
|
|
}
|
|
m.Claims[0].Serves = VerbNames(seat.Serves)
|
|
if err := CanHold(m, seat); err != nil {
|
|
t.Fatalf("a holder serving every verb: %v", err)
|
|
}
|
|
// Every other verb is still a condition of holding.
|
|
m.Claims[0].Serves = append([]string{"checks"}, before[1:]...)
|
|
if err := CanHold(m, seat); err == nil || !strings.Contains(err.Error(), before[0]) {
|
|
t.Fatalf("a holder without %s: %v", before[0], err)
|
|
}
|
|
}
|