(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestParseAgentPickerRefsDefaults(t *testing.T) { |
| 60 | home := t.TempDir() |
| 61 | t.Setenv("HOME", home) |
| 62 | t.Setenv("USERPROFILE", home) // os.UserHomeDir on Windows |
| 63 | |
| 64 | // Without ~/.agents, only the built-in agents are offered. |
| 65 | for _, raw := range []string{"", " ", ",,,"} { |
| 66 | assert.Equal(t, []string{"default", "coder"}, parseAgentPickerRefs(raw)) |
| 67 | } |
| 68 | |
| 69 | // Config files in ~/.agents are appended to the built-ins; directories |
| 70 | // (e.g. skills) and non-config files are ignored. |
| 71 | agentsDir := filepath.Join(home, ".agents") |
| 72 | require.NoError(t, os.MkdirAll(filepath.Join(agentsDir, "skills"), 0o755)) |
| 73 | for _, name := range []string{"assistant.yaml", "gopher.yml", "notes.txt"} { |
| 74 | require.NoError(t, os.WriteFile(filepath.Join(agentsDir, name), nil, 0o644)) |
| 75 | } |
| 76 | |
| 77 | want := []string{ |
| 78 | "default", |
| 79 | "coder", |
| 80 | filepath.Join(agentsDir, "assistant.yaml"), |
| 81 | filepath.Join(agentsDir, "gopher.yml"), |
| 82 | } |
| 83 | assert.Equal(t, want, parseAgentPickerRefs("")) |
| 84 | |
| 85 | // The NoOptDefVal sentinel behaves like an empty spec. |
| 86 | assert.Equal(t, want, parseAgentPickerRefs(agentPickerDefaultsSpec)) |
| 87 | |
| 88 | // An explicit list bypasses the defaults entirely. |
| 89 | assert.Equal(t, []string{"coder"}, parseAgentPickerRefs("coder")) |
| 90 | } |
| 91 | |
| 92 | func TestAgentRefsInDirSkipsNonRegularFiles(t *testing.T) { |
| 93 | t.Parallel() |
nothing calls this directly
no test coverage detected