-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands_agent_loop_test.go
More file actions
74 lines (65 loc) · 1.92 KB
/
Copy pathcommands_agent_loop_test.go
File metadata and controls
74 lines (65 loc) · 1.92 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
package main
import (
"testing"
sdk "github.com/modelrelay/modelrelay/sdk/go"
)
func TestParseLoopTools(t *testing.T) {
selection, err := parseLoopTools([]string{"bash,tasks.write"}, false)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !selection.enableBash || !selection.enableTasks {
t.Fatalf("expected both bash and tasks.write enabled, got %+v", selection)
}
}
func TestParseLoopToolsUnknown(t *testing.T) {
_, err := parseLoopTools([]string{"unknown"}, false)
if err == nil {
t.Fatal("expected error for unknown tool")
}
}
func TestParseLoopToolsFS(t *testing.T) {
selection, err := parseLoopTools([]string{"fs"}, false)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !selection.enableFS {
t.Fatalf("expected fs enabled, got %+v", selection)
}
}
func TestParseLoopToolsAllowEmpty(t *testing.T) {
selection, err := parseLoopTools(nil, true)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if selection.enableBash || selection.enableTasks || selection.enableFS {
t.Fatalf("expected no tools enabled, got %+v", selection)
}
}
func TestParseBashRules(t *testing.T) {
rules, err := parseBashRules([]string{"exact:git status", "prefix:go ", "regexp:^ls"})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, ok := rules[0].(sdk.BashCommandExact); !ok {
t.Fatalf("expected exact rule, got %T", rules[0])
}
if _, ok := rules[1].(sdk.BashCommandPrefix); !ok {
t.Fatalf("expected prefix rule, got %T", rules[1])
}
if _, ok := rules[2].(sdk.BashCommandRegexp); !ok {
t.Fatalf("expected regexp rule, got %T", rules[2])
}
}
func TestTasksWriteArgsValidate(t *testing.T) {
args := tasksWriteArgs{
Tasks: []runTask{{Content: "one", Status: runTaskStatusPending}},
}
if err := args.Validate(); err != nil {
t.Fatalf("unexpected error: %v", err)
}
args.Tasks[0].Status = "nope"
if err := args.Validate(); err == nil {
t.Fatal("expected validation error")
}
}