(t *testing.T)
| 287 | } |
| 288 | |
| 289 | func TestResolveSandboxDefault(t *testing.T) { |
| 290 | t.Parallel() |
| 291 | |
| 292 | dir := t.TempDir() |
| 293 | sbxPath := filepath.Join(dir, "runtime-sandbox.yaml") |
| 294 | require.NoError(t, os.WriteFile(sbxPath, |
| 295 | []byte("runtime:\n sandbox: true\nagents:\n root:\n model: openai/gpt-4o\n description: t\n instruction: t\n"), |
| 296 | 0o600)) |
| 297 | plainPath := filepath.Join(dir, "plain.yaml") |
| 298 | require.NoError(t, os.WriteFile(plainPath, |
| 299 | []byte("agents:\n root:\n model: openai/gpt-4o\n description: t\n instruction: t\n"), |
| 300 | 0o600)) |
| 301 | |
| 302 | tests := []struct { |
| 303 | name string |
| 304 | agentRef string |
| 305 | current bool |
| 306 | want bool |
| 307 | wantCfg bool |
| 308 | }{ |
| 309 | {"empty ref, flag false", "", false, false, false}, |
| 310 | {"empty ref, flag already true", "", true, true, false}, |
| 311 | {"runtime.sandbox: true picked up", sbxPath, false, true, true}, |
| 312 | {"plain agent stays false", plainPath, false, false, true}, |
| 313 | {"current=true short-circuits the decision", plainPath, true, true, true}, |
| 314 | {"unresolvable ref stays false", filepath.Join(dir, "missing.yaml"), false, false, false}, |
| 315 | } |
| 316 | |
| 317 | for _, tt := range tests { |
| 318 | t.Run(tt.name, func(t *testing.T) { |
| 319 | got, cfg := resolveSandboxDefault(t.Context(), tt.agentRef, tt.current) |
| 320 | assert.Equal(t, tt.want, got) |
| 321 | assert.Equal(t, tt.wantCfg, cfg != nil) |
| 322 | }) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | func TestPeekAgentSandbox(t *testing.T) { |
| 327 | t.Parallel() |
nothing calls this directly
no test coverage detected