From a4f93b52a8994c5a21fa7b362dc5b76b686b4cab Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 10 Oct 2026 20:55:43 +0200 Subject: [PATCH] Test that a delivery seat holder without times still holds the seat, and one serving it is not refused (hq issue 382, review of #206) --- internal/catalogue/delivery_seat_test.go | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/internal/catalogue/delivery_seat_test.go b/internal/catalogue/delivery_seat_test.go index 55fc7afe..5fe8daf2 100644 --- a/internal/catalogue/delivery_seat_test.go +++ b/internal/catalogue/delivery_seat_test.go @@ -97,3 +97,39 @@ func TestTheDeliverySeatPromisesRetireHistoryOptionally(t *testing.T) { t.Fatalf("a holder serving retire-history: %v", err) } } + +// The seat says delivery times (novox/hq ADR 0282, issue 382): `times`, over some days or for one delivery. Added +// after the holder shipped, it is optional, so the holder that does not serve it yet still holds the seat, and one +// that does is not refused for a verb the seat lacks. +func TestTheDeliverySeatPromisesTimesOptionally(t *testing.T) { + seat, _ := SeatNamed(DeliverySeat) + var times *Verb + for i := range seat.Serves { + if seat.Serves[i].Name == "times" { + times = &seat.Serves[i] + } + } + if times == nil || !times.Optional { + t.Fatalf("the delivery seat promises %v, times optionally", VerbNames(seat.Serves)) + } + props, _ := times.Input["properties"].(map[string]any) + for _, arg := range []string{"days", "id"} { + if _, has := props[arg]; !has { + t.Errorf("times takes no %q", arg) + } + } + var without []string + for _, v := range VerbNames(seat.Serves) { + if v != "times" { + without = append(without, v) + } + } + m := Manifest{Module: "mesh-delivery", Claims: []Claim{{Name: DeliverySeat, Scope: ScopeMesh, Serves: without}}} + if err := CanHold(m, seat); err != nil { + t.Fatalf("a holder without times yet: %v", err) + } + m.Claims[0].Serves = VerbNames(seat.Serves) + if err := CanHold(m, seat); err != nil { + t.Fatalf("a holder serving times: %v", err) + } +}