oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thin
2
3import (
4 "encoding/json"
5 "testing"
6
7 "amadan.net/oficina/equipo/internal/wire"
8)
9
10// TestExploreRefusedBelow10: an exploration is answered here on a
11// connection below protocol 10, before sending and in place of an older
12// instance's strict refusal of a call queued at 10; a change, protocol 10,
13// an unknown protocol and a stored success are never touched.
14func TestExploreRefusedBelow10(t *testing.T) {
15 explore := wire.ToolCall{Name: wire.ToolRecordTask, Args: json.RawMessage(`{"repo":"r","title":"t","brief":"b","kind":"explore"}`)}
16 change := wire.ToolCall{Name: wire.ToolRecordTask, Args: json.RawMessage(`{"repo":"r","title":"t","brief":"b","kind":"change"}`)}
17 invalid := wire.ToolResult{IsError: true, Code: "invalid", Text: "bad input"}
18 ok := wire.ToolResult{Code: "recorded", Text: "{}"}
19 for name, c := range map[string]struct {
20 call wire.ToolCall
21 spoken int
22 res *wire.ToolResult
23 refused bool
24 }{
25 "before sending at 9": {explore, wire.ProtocolPreview, nil, true},
26 "an older refusal at 9": {explore, wire.ProtocolPreview, &invalid, true},
27 "a stored success at 9": {explore, wire.ProtocolPreview, &ok, false},
28 "at 10": {explore, wire.ProtocolExplore, nil, false},
29 "protocol unknown": {explore, 0, nil, false},
30 "a change at 9": {change, wire.ProtocolPreview, &invalid, false},
31 } {
32 res, refused := exploreRefused(c.call, c.spoken, c.res)
33 if refused != c.refused || refused && (res.Code != "explore_unsupported" || !res.IsError || res.Text != toolExploreOld) {
34 t.Errorf("%s: %+v %t", name, res, refused)
35 }
36 }
37}
38