Debian Codegraph @

act_protocol_test.go

raw
1 package clnkr
2
3 import (
4 "strings"
5 "testing"
6 )
7
8 func TestParseActProtocol(t *testing.T) {
9 tests := []struct {
10 name string
11 raw string
12 want ActProtocol
13 }{
14 {name: "default", want: ActProtocolClnkrInline},
15 {name: "trim lower", raw: " TOOL-CALLS ", want: ActProtocolToolCalls},
16 {name: "inline", raw: "clnkr-inline", want: ActProtocolClnkrInline},
17 }
18
19 for _, tc := range tests {
20 t.Run(tc.name, func(t *testing.T) {
21 got, err := ParseActProtocol(tc.raw)
22 if err != nil {
23 t.Fatalf("ParseActProtocol(%q): %v", tc.raw, err)
24 }
25 if got != tc.want {
26 t.Fatalf("ParseActProtocol(%q) = %q, want %q", tc.raw, got, tc.want)
27 }
28 })
29 }
30 }
31
32 func TestParseActProtocolRejectsOldValues(t *testing.T) {
33 for _, raw := range []string{"structured-json", "native-bash-tools", "text-json"} {
34 t.Run(raw, func(t *testing.T) {
35 _, err := ParseActProtocol(raw)
36 if err == nil {
37 t.Fatalf("ParseActProtocol(%q) succeeded", raw)
38 }
39 if !strings.Contains(err.Error(), `invalid act-protocol`) {
40 t.Fatalf("error = %q, want act-protocol validation", err)
41 }
42 if !strings.Contains(err.Error(), "clnkr-inline, tool-calls") {
43 t.Fatalf("error = %q, want allowed act protocol values", err)
44 }
45 })
46 }
47 }