MCPcopy Create free account
hub / github.com/coder/coder / TestToolResultSize

Function TestToolResultSize

coderd/x/chatd/chatloop/metrics_test.go:147–198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestToolResultSize(t *testing.T) {
148 t.Parallel()
149
150 tests := []struct {
151 name string
152 result fantasy.ToolResultContent
153 expected int
154 }{
155 {
156 name: "text",
157 result: fantasy.ToolResultContent{
158 Result: fantasy.ToolResultOutputContentText{Text: "hello"},
159 },
160 expected: 5,
161 },
162 {
163 name: "error",
164 result: fantasy.ToolResultContent{
165 Result: fantasy.ToolResultOutputContentError{
166 Error: assert.AnError,
167 },
168 },
169 expected: len(assert.AnError.Error()),
170 },
171 {
172 name: "media",
173 result: fantasy.ToolResultContent{
174 Result: fantasy.ToolResultOutputContentMedia{Data: "base64data"},
175 },
176 expected: 10,
177 },
178 {
179 name: "nil_result",
180 result: fantasy.ToolResultContent{},
181 expected: 0,
182 },
183 {
184 name: "error_nil_error",
185 result: fantasy.ToolResultContent{
186 Result: fantasy.ToolResultOutputContentError{Error: nil},
187 },
188 expected: 0,
189 },
190 }
191
192 for _, tt := range tests {
193 t.Run(tt.name, func(t *testing.T) {
194 t.Parallel()
195 assert.Equal(t, tt.expected, chatloop.ToolResultSize(tt.result))
196 })
197 }
198}
199
200func TestRecordCompaction(t *testing.T) {
201 t.Parallel()

Callers

nothing calls this directly

Calls 4

ToolResultSizeFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected