-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclaude_test.go
More file actions
80 lines (69 loc) · 1.83 KB
/
Copy pathclaude_test.go
File metadata and controls
80 lines (69 loc) · 1.83 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
package claude
import (
"testing"
)
func TestNewWithTools(t *testing.T) {
tests := []struct {
name string
tools []string
expectEnabled bool
}{
{
name: "All tools allowed (nil)",
tools: nil,
expectEnabled: true,
},
{
name: "Specific tools allowed",
tools: []string{"Read", "Grep", "Glob"},
expectEnabled: true,
},
{
name: "All tools disabled (empty slice)",
tools: []string{},
expectEnabled: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := NewWithTools("/tmp", "test", tt.tools)
if client.EnableTools != tt.expectEnabled {
t.Errorf("EnableTools = %v, want %v", client.EnableTools, tt.expectEnabled)
}
if len(tt.tools) > 0 {
if len(client.AllowedTools) != len(tt.tools) {
t.Errorf("AllowedTools length = %d, want %d", len(client.AllowedTools), len(tt.tools))
}
}
})
}
}
func TestNewWithTmux_BackwardCompat(t *testing.T) {
client := NewWithTmux("/tmp", "test")
if client.EnableTools {
t.Error("NewWithTmux should disable tools for backward compatibility")
}
if client.AllowedTools != nil {
t.Error("NewWithTmux should have nil AllowedTools")
}
}
func TestStreamingArgsIncludesMCPConfig(t *testing.T) {
client := NewWithWorkDir("/tmp")
client.EnableTools = true
client.MCPConfigs = []string{`{"mcpServers":{"datadog":{"command":"npx"}}}`}
args := client.streamingArgs()
if !containsArg(args, "--mcp-config") || !containsArg(args, client.MCPConfigs[0]) {
t.Fatalf("args = %#v, want MCP config", args)
}
if containsArg(args, "--tools") {
t.Fatalf("args = %#v, should not disable tools when MCP config is present", args)
}
}
func containsArg(args []string, want string) bool {
for _, arg := range args {
if arg == want {
return true
}
}
return false
}