@@ -3,58 +3,13 @@ package creator
33import (
44 "testing"
55
6- "github.com/goccy/go-yaml"
76 "github.com/stretchr/testify/assert"
87 "github.com/stretchr/testify/require"
98
109 "github.com/docker/docker-agent/pkg/config"
11- "github.com/docker/docker-agent/pkg/config/latest"
1210 "github.com/docker/docker-agent/pkg/environment"
1311)
1412
15- func TestAgentConfigYAML (t * testing.T ) {
16- t .Parallel ()
17-
18- // Build the same structure as the buildCreatorConfigYAML function
19- agentToolsets := []map [string ]any {
20- {"type" : "shell" },
21- {"type" : "filesystem" },
22- }
23-
24- rootAgent := yaml.MapSlice {
25- {Key : "model" , Value : "auto" },
26- {Key : "welcome_message" , Value : "Hello! I'm here to create agents for you.\n \n Can you explain to me what the agent will be used for?" },
27- {Key : "instruction" , Value : "Some test instructions" },
28- {Key : "toolsets" , Value : agentToolsets },
29- }
30-
31- agentsMapSlice := yaml.MapSlice {
32- {Key : "root" , Value : rootAgent },
33- }
34-
35- newAgentConfig := yaml.MapSlice {
36- {Key : "agents" , Value : agentsMapSlice },
37- }
38-
39- data , err := yaml .Marshal (newAgentConfig )
40- require .NoError (t , err )
41-
42- t .Logf ("YAML output:\n %s" , string (data ))
43-
44- // Verify it can be loaded by the config loader
45- cfg , err := config .Load (t .Context (), config .NewBytesSource ("test" , data ))
46- require .NoError (t , err )
47-
48- // Verify the config has the expected structure
49- require .Len (t , cfg .Agents , 1 )
50- assert .Equal (t , "root" , cfg .Agents [0 ].Name )
51- assert .Equal (t , "auto" , cfg .Agents [0 ].Model )
52- assert .Contains (t , cfg .Agents [0 ].WelcomeMessage , "Hello!" )
53- require .Len (t , cfg .Agents [0 ].Toolsets , 2 )
54- assert .Equal (t , "shell" , cfg .Agents [0 ].Toolsets [0 ].Type )
55- assert .Equal (t , "filesystem" , cfg .Agents [0 ].Toolsets [1 ].Type )
56- }
57-
5813func TestBuildCreatorConfigYAML (t * testing.T ) {
5914 t .Parallel ()
6015
@@ -144,45 +99,6 @@ func TestAgent(t *testing.T) {
14499 assert .Contains (t , toolNames , "write_file" )
145100}
146101
147- func TestFileWriteTracker (t * testing.T ) {
148- t .Parallel ()
149-
150- ctx := t .Context ()
151- runConfig := & config.RuntimeConfig {
152- Config : config.Config {
153- WorkingDir : t .TempDir (),
154- },
155- }
156-
157- registry := createToolsetRegistry (runConfig .WorkingDir )
158- require .NotNil (t , registry )
159-
160- // Create the toolset through the registry
161- toolset , err := registry .CreateTool (ctx , latest.Toolset {Type : "filesystem" }, runConfig .WorkingDir , runConfig , "test-agent" )
162- require .NoError (t , err )
163- require .NotNil (t , toolset )
164-
165- // Verify the toolset is a file write tracker
166- tracker , ok := toolset .(* fileWriteTracker )
167- require .True (t , ok , "expected fileWriteTracker, got %T" , toolset )
168-
169- // Initially, no path should be tracked
170- assert .Empty (t , tracker .LastWrittenPath ())
171-
172- // Get the tools and verify write_file is present
173- tools , err := tracker .Tools (ctx )
174- require .NoError (t , err )
175-
176- var hasWriteFile bool
177- for _ , tool := range tools {
178- if tool .Name == "write_file" {
179- hasWriteFile = true
180- break
181- }
182- }
183- assert .True (t , hasWriteFile , "write_file tool should be present" )
184- }
185-
186102func TestBuildCreatorConfigYAML_MultilineStrings (t * testing.T ) {
187103 t .Parallel ()
188104
0 commit comments