-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathlist_test.go
More file actions
79 lines (73 loc) · 1.66 KB
/
list_test.go
File metadata and controls
79 lines (73 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package tools
import (
"testing"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/stretchr/testify/assert"
)
func TestToolDescription(t *testing.T) {
tests := []struct {
name string
tool *mcp.Tool
expected string
}{
{
name: "uses title from annotations when available",
tool: &mcp.Tool{
Name: "test-tool",
Description: "Longer description",
Annotations: &mcp.ToolAnnotations{
Title: "Short Title",
},
},
expected: "Short Title",
},
{
name: "falls back to description when no title",
tool: &mcp.Tool{
Name: "test-tool",
Description: "Simple description.",
},
expected: "Simple description.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := toolDescription(tt.tool)
assert.Equal(t, tt.expected, result)
})
}
}
func TestDescriptionSummary(t *testing.T) {
tests := []struct {
name string
description string
expected string
}{
{
name: "single sentence",
description: "This is a simple description.",
expected: "This is a simple description.",
},
{
name: "multiple sentences - takes first",
description: "First sentence. Second sentence.",
expected: "First sentence.",
},
{
name: "empty description",
description: "",
expected: "",
},
{
name: "stops at Error Responses",
description: "Tool description.\nError Responses:\n- 404 if not found",
expected: "Tool description.",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := descriptionSummary(tt.description)
assert.Equal(t, tt.expected, result)
})
}
}