Skip to content

Commit 1782337

Browse files
authored
Merge pull request #724 from dgageot/tool-format-tests
Add tests for tool call formatting
2 parents 5db418f + 0876d58 commit 1782337

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

pkg/cli/text_test.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package cli
2+
3+
import (
4+
"testing"
5+
6+
"gotest.tools/v3/assert"
7+
)
8+
9+
func TestFormatToolCallResponse_Empty(t *testing.T) {
10+
formatted := formatToolCallResponse(``)
11+
12+
assert.Equal(t, ` → ()`, formatted)
13+
}
14+
15+
func TestFormatToolCallResponse_Map(t *testing.T) {
16+
formatted := formatToolCallResponse(`{"text": "hello"}`)
17+
18+
assert.Equal(t, ` → (text: "hello")`, formatted)
19+
}
20+
21+
func TestFormatToolCallResponse_MapOfEmptyArray(t *testing.T) {
22+
formatted := formatToolCallResponse(`{"array": []}`)
23+
assert.Equal(t, ` → (array: [])`, formatted)
24+
}
25+
26+
func TestFormatToolCallResponse_MapOfArray(t *testing.T) {
27+
formatted := formatToolCallResponse(`{"array": [1,2,3]}`)
28+
assert.Equal(t, ` → (
29+
array: [
30+
1,
31+
2,
32+
3
33+
]
34+
)`, formatted)
35+
}
36+
37+
func TestFormatToolCallResponse_PlainText(t *testing.T) {
38+
formatted := formatToolCallResponse(`Plain Text`)
39+
40+
assert.Equal(t, ` → "Plain Text"`, formatted)
41+
}
42+
43+
func TestFormatToolCallArguments_Empty(t *testing.T) {
44+
formatted := formatToolCallArguments(``)
45+
46+
assert.Equal(t, `()`, formatted)
47+
}
48+
49+
func TestFormatToolCallArguments_Map(t *testing.T) {
50+
formatted := formatToolCallArguments(`{"text": "hello"}`)
51+
52+
assert.Equal(t, `(text: "hello")`, formatted)
53+
}
54+
55+
func TestFormatToolCallArguments_MapOfArray(t *testing.T) {
56+
formatted := formatToolCallArguments(`{"array": [1,2,3]}`)
57+
assert.Equal(t, `(
58+
array: [
59+
1,
60+
2,
61+
3
62+
]
63+
)`, formatted)
64+
}
65+
66+
func TestFormatToolCallArguments_MapOfEmptyArray(t *testing.T) {
67+
formatted := formatToolCallArguments(`{"array": []}`)
68+
assert.Equal(t, `(array: [])`, formatted)
69+
}
70+
71+
func TestFormatToolCallArguments_PlainText(t *testing.T) {
72+
formatted := formatToolCallArguments(`Plain Text`)
73+
74+
assert.Equal(t, `(Plain Text)`, formatted)
75+
}

0 commit comments

Comments
 (0)