Download this file
| 1 | package coordinator |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/runnerproto" |
| 5 | "errors" |
| 6 | "fmt" |
| 7 | "strings" |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | func TestCoordinatorContextRequestRequired(t *testing.T) { |
| 12 | for _, body := range []string{strings.Repeat("\x00", 16000), strings.Repeat("x", 16000)} { |
| 13 | c := contextFixture() |
| 14 | c.ConfirmedDecisions[0].Text = strings.Repeat("d", 40000) |
| 15 | c.Recent = []runnerproto.MessageRef{{ID: "request", Body: body}} |
| 16 | if _, err := runnerproto.BoundCoordinatorContext(c); !errors.Is(err, runnerproto.ErrPromptTooLarge) { |
| 17 | t.Fatal("admitted request was trimmed", err) |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | func TestCoordinatorContextFiftySmallMessages(t *testing.T) { |
| 22 | c := contextFixture() |
| 23 | for i := 0; i < 60; i++ { |
| 24 | c.Recent = append(c.Recent, runnerproto.MessageRef{ID: fmt.Sprint(i), Body: "small"}) |
| 25 | } |
| 26 | got, err := runnerproto.BoundCoordinatorContext(c) |
| 27 | if err != nil || len(got.Recent) != 50 || got.Recent[0].ID != "10" || got.Recent[49].ID != "59" { |
| 28 | t.Fatal("message count bound lost", len(got.Recent), err) |
| 29 | } |
| 30 | } |
| 31 | |