package coordinator import ( "amadan.net/oficina/equipo/internal/runnerproto" "errors" "fmt" "strings" "testing" ) func TestCoordinatorContextRequestRequired(t *testing.T) { for _, body := range []string{strings.Repeat("\x00", 16000), strings.Repeat("x", 16000)} { c := contextFixture() c.ConfirmedDecisions[0].Text = strings.Repeat("d", 40000) c.Recent = []runnerproto.MessageRef{{ID: "request", Body: body}} if _, err := runnerproto.BoundCoordinatorContext(c); !errors.Is(err, runnerproto.ErrPromptTooLarge) { t.Fatal("admitted request was trimmed", err) } } } func TestCoordinatorContextFiftySmallMessages(t *testing.T) { c := contextFixture() for i := 0; i < 60; i++ { c.Recent = append(c.Recent, runnerproto.MessageRef{ID: fmt.Sprint(i), Body: "small"}) } got, err := runnerproto.BoundCoordinatorContext(c) if err != nil || len(got.Recent) != 50 || got.Recent[0].ID != "10" || got.Recent[49].ID != "59" { t.Fatal("message count bound lost", len(got.Recent), err) } }