-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathagent_util_test.go
More file actions
87 lines (80 loc) · 1.99 KB
/
Copy pathagent_util_test.go
File metadata and controls
87 lines (80 loc) · 1.99 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
package main
import (
"testing"
)
func TestParseAgentString(t *testing.T) {
// Save the original builtinAgents and restore it after the test
originalBuiltins := builtinAgents
defer func() { builtinAgents = originalBuiltins }()
// Set up some test builtin agents
builtinAgents = map[string]string{
"coder": "# test content",
"auto": "# test content",
}
tests := []struct {
name string
input string
expectName string
expectPathFunc func(path string) bool // Function to verify path
}{
{
name: "Plus prefix builtin",
input: "+coder",
expectName: "coder",
expectPathFunc: func(path string) bool {
return path == "builtin:coder"
},
},
{
name: "Plus prefix user agent",
input: "+custom",
expectName: "custom",
expectPathFunc: func(path string) bool {
return path != "" && path != "builtin:custom"
},
},
{
name: "Absolute path",
input: "/path/to/agent.toml",
expectName: "",
expectPathFunc: func(path string) bool {
return path == "/path/to/agent.toml"
},
},
{
name: "Relative path with tilde",
input: "~/agents/custom.toml",
expectName: "",
expectPathFunc: func(path string) bool {
return path != "~/agents/custom.toml" // Should be expanded
},
},
{
name: "Name only for builtin",
input: "auto",
expectName: "auto",
expectPathFunc: func(path string) bool {
return path == "builtin:auto"
},
},
{
name: "Name only for user agent",
input: "custom",
expectName: "custom",
expectPathFunc: func(path string) bool {
return path != "" && path != "builtin:custom"
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
name, path := ParseAgentString(tt.input)
if name != tt.expectName {
t.Errorf("Expected name %q, got %q", tt.expectName, name)
}
if !tt.expectPathFunc(path) {
t.Errorf("Path validation failed for %q, got %q", tt.input, path)
}
})
}
}