-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathregister_test.go
More file actions
98 lines (88 loc) · 2.64 KB
/
register_test.go
File metadata and controls
98 lines (88 loc) · 2.64 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package cmd
import (
"strings"
"testing"
"github.com/mcpjungle/mcpjungle/pkg/types"
)
func TestReadMcpServerConfigJson(t *testing.T) {
input := `{
"name": "test_server",
"transport": "stdio",
"description": "Test JSON server",
"command": "node",
"args": ["server.js"],
"env": {"NODE_ENV": "test"}
}`
reader := strings.NewReader(input)
got, err := readMcpServerConfigJson(reader)
if err != nil {
t.Fatalf("readMcpServerConfigJson() error = %v", err)
}
expected := types.RegisterServerInput{
Name: "test_server",
Transport: "stdio",
Description: "Test JSON server",
Command: "node",
Args: []string{"server.js"},
Env: map[string]string{"NODE_ENV": "test"},
}
if got.Name != expected.Name {
t.Errorf("Name = %q, want %q", got.Name, expected.Name)
}
if got.Transport != expected.Transport {
t.Errorf("Transport = %q, want %q", got.Transport, expected.Transport)
}
if got.Description != expected.Description {
t.Errorf("Description = %q, want %q", got.Description, expected.Description)
}
if got.Command != expected.Command {
t.Errorf("Command = %q, want %q", got.Command, expected.Command)
}
if len(got.Args) != len(expected.Args) || got.Args[0] != expected.Args[0] {
t.Errorf("Args = %v, want %v", got.Args, expected.Args)
}
if got.Env["NODE_ENV"] != expected.Env["NODE_ENV"] {
t.Errorf("Env = %v, want %v", got.Env, expected.Env)
}
}
func TestReadMcpServerConfigYaml(t *testing.T) {
input := `name: test_server
transport: stdio
description: Test YAML server
command: node
args:
- server.js
env:
NODE_ENV: test`
reader := strings.NewReader(input)
got, err := readMcpServerConfigYaml(reader)
if err != nil {
t.Fatalf("readMcpServerConfigYaml() error = %v", err)
}
expected := types.RegisterServerInput{
Name: "test_server",
Transport: "stdio",
Description: "Test YAML server",
Command: "node",
Args: []string{"server.js"},
Env: map[string]string{"NODE_ENV": "test"},
}
if got.Name != expected.Name {
t.Errorf("Name = %q, want %q", got.Name, expected.Name)
}
if got.Transport != expected.Transport {
t.Errorf("Transport = %q, want %q", got.Transport, expected.Transport)
}
if got.Description != expected.Description {
t.Errorf("Description = %q, want %q", got.Description, expected.Description)
}
if got.Command != expected.Command {
t.Errorf("Command = %q, want %q", got.Command, expected.Command)
}
if len(got.Args) != len(expected.Args) || got.Args[0] != expected.Args[0] {
t.Errorf("Args = %v, want %v", got.Args, expected.Args)
}
if got.Env["NODE_ENV"] != expected.Env["NODE_ENV"] {
t.Errorf("Env = %v, want %v", got.Env, expected.Env)
}
}