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

Function TestParseConfig

agent/x/agentmcp/config_test.go:14–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestParseConfig(t *testing.T) {
15 t.Parallel()
16
17 tests := []struct {
18 name string
19 content string
20 expected []agentmcp.ServerConfig
21 expectError bool
22 }{
23 {
24 name: "StdioServer",
25 content: mustJSON(t, map[string]any{
26 "mcpServers": map[string]any{
27 "my-server": map[string]any{
28 "command": "npx",
29 "args": []string{"-y", "@example/mcp-server"},
30 "env": map[string]string{"FOO": "bar"},
31 },
32 },
33 }),
34 expected: []agentmcp.ServerConfig{
35 {
36 Name: "my-server",
37 Transport: "stdio",
38 Command: "npx",
39 Args: []string{"-y", "@example/mcp-server"},
40 Env: map[string]string{"FOO": "bar"},
41 },
42 },
43 },
44 {
45 name: "HTTPServer",
46 content: mustJSON(t, map[string]any{
47 "mcpServers": map[string]any{
48 "remote": map[string]any{
49 "url": "https://example.com/mcp",
50 "headers": map[string]string{"Authorization": "Bearer tok"},
51 },
52 },
53 }),
54 expected: []agentmcp.ServerConfig{
55 {
56 Name: "remote",
57 Transport: "http",
58 URL: "https://example.com/mcp",
59 Headers: map[string]string{"Authorization": "Bearer tok"},
60 },
61 },
62 },
63 {
64 name: "SSEServer",
65 content: mustJSON(t, map[string]any{
66 "mcpServers": map[string]any{
67 "events": map[string]any{
68 "type": "sse",
69 "url": "https://example.com/sse",
70 },
71 },

Callers

nothing calls this directly

Calls 7

ParseConfigFunction · 0.92
mustJSONFunction · 0.70
RunMethod · 0.65
TempDirMethod · 0.65
WriteFileMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected