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

Function TestSplitToolName

agent/x/agentmcp/manager_internal_test.go:26–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestSplitToolName(t *testing.T) {
27 t.Parallel()
28
29 tests := []struct {
30 name string
31 input string
32 wantServer string
33 wantTool string
34 wantErr bool
35 }{
36 {
37 name: "Valid",
38 input: "server__tool",
39 wantServer: "server",
40 wantTool: "tool",
41 },
42 {
43 name: "ValidWithUnderscoresInTool",
44 input: "server__my_tool",
45 wantServer: "server",
46 wantTool: "my_tool",
47 },
48 {
49 name: "MissingSeparator",
50 input: "servertool",
51 wantErr: true,
52 },
53 {
54 name: "EmptyServer",
55 input: "__tool",
56 wantErr: true,
57 },
58 {
59 name: "EmptyTool",
60 input: "server__",
61 wantErr: true,
62 },
63 {
64 name: "JustSeparator",
65 input: "__",
66 wantErr: true,
67 },
68 }
69
70 for _, tt := range tests {
71 t.Run(tt.name, func(t *testing.T) {
72 t.Parallel()
73
74 server, tool, err := splitToolName(tt.input)
75 if tt.wantErr {
76 require.Error(t, err)
77 assert.ErrorIs(t, err, ErrInvalidToolName)
78 return
79 }
80 require.NoError(t, err)
81 assert.Equal(t, tt.wantServer, server)
82 assert.Equal(t, tt.wantTool, tool)
83 })

Callers

nothing calls this directly

Calls 4

splitToolNameFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected