Rationalized the default configuration file path and updated documentation
All checks were successful
ci/woodpecker/tag/release Pipeline was successful

This commit is contained in:
2026-05-14 20:48:12 -05:00
parent b09966f076
commit 77134c3c78
4 changed files with 85 additions and 4 deletions

View File

@@ -132,6 +132,53 @@ func TestLoadConfigEmptyFileResolvesToBuiltInDefaults(t *testing.T) {
}
}
func TestLoadConfigImplicitSearchPrefersUsrLocalEtcOverEtc(t *testing.T) {
tmp := t.TempDir()
localPath := filepath.Join(tmp, "usr-local.yml")
etcPath := filepath.Join(tmp, "etc.yml")
if err := os.WriteFile(localPath, []byte("prompt_dir: ./from-usr-local\n"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(etcPath, []byte("prompt_dir: ./from-etc\n"), 0o644); err != nil {
t.Fatal(err)
}
orig := defaultConfigSearchPaths
defaultConfigSearchPaths = []string{localPath, etcPath}
t.Cleanup(func() { defaultConfigSearchPaths = orig })
got, err := LoadConfig("", false)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if got.PromptDir != filepath.Clean("./from-usr-local") {
t.Fatalf("expected usr-local config to win, got prompt_dir=%q", got.PromptDir)
}
}
func TestLoadConfigImplicitSearchFallsBackToEtcWhenUsrLocalMissing(t *testing.T) {
tmp := t.TempDir()
missingLocal := filepath.Join(tmp, "missing-local.yml")
etcPath := filepath.Join(tmp, "etc.yml")
if err := os.WriteFile(etcPath, []byte("prompt_dir: ./from-etc\n"), 0o644); err != nil {
t.Fatal(err)
}
orig := defaultConfigSearchPaths
defaultConfigSearchPaths = []string{missingLocal, etcPath}
t.Cleanup(func() { defaultConfigSearchPaths = orig })
got, err := LoadConfig("", false)
if err != nil {
t.Fatalf("expected no error, got %v", err)
}
if got.PromptDir != filepath.Clean("./from-etc") {
t.Fatalf("expected etc fallback config, got prompt_dir=%q", got.PromptDir)
}
}
func TestApplyCLIOverridesAppliesPrecedence(t *testing.T) {
base := AppSettings{
PromptDir: "/from/config/prompts",