The merged message and the catch-up asked the seat's groups with all=true, whose answer outgrew one bus message (2888983 bytes, live 02:06), so no take-in answered. Read asks the open groups, MergedOf the one group its branch names (group=<id>); the list a person asks (bridge_groups) keeps ReadAll. Builds: lead: principle 7, live 02:06 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package groups
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
|
)
|
|
|
|
// The seat answers the whole list of groups with more than one bus message carries once many have ended (live 02:06);
|
|
// a read of the open ones, or of one by its id, is answered; Read never asks for all (lead: principle 7).
|
|
func TestReadsNeverAskTheEndedGroupsWhole(t *testing.T) {
|
|
const bus = 1 << 20
|
|
seatOf := func(_ context.Context, _ string, body any) (json.RawMessage, error) {
|
|
in := body.(seat.GroupsInput)
|
|
groups := []seat.Group{{ID: "feat/open", State: "gathering"}}
|
|
switch {
|
|
case in.Group != "":
|
|
groups = []seat.Group{{ID: in.Group}}
|
|
case in.All == seat.GroupsInputAllTrue:
|
|
for i := 0; i < 3000; i++ {
|
|
groups = append(groups, seat.Group{ID: "ended", Why: strings.Repeat("x", 500)})
|
|
}
|
|
}
|
|
raw, _ := json.Marshal(seat.GroupsAnswer{Groups: groups})
|
|
if len(raw) > bus {
|
|
return nil, errors.New("the answer is more than the bus carries in one message")
|
|
}
|
|
return raw, nil
|
|
}
|
|
if got, err := Read(context.Background(), seatOf); err != nil || len(got) != 1 || got[0].ID != "feat/open" {
|
|
t.Errorf("Read: %v %v; want the open group alone", got, err)
|
|
}
|
|
if got, err := ReadGroup(context.Background(), seatOf, "feat/ended"); err != nil || len(got) != 1 || got[0].ID != "feat/ended" {
|
|
t.Errorf("ReadGroup: %v %v; want the group by its id", got, err)
|
|
}
|
|
if _, err := ReadAll(context.Background(), seatOf); err == nil {
|
|
t.Errorf("ReadAll: want the seat's refusal to be an error, never read as no group")
|
|
}
|
|
}
|