test: verificar que Load() puebla ConfigDir correctamente
Test con directorio anidado (agents/_specials/father-bot/) que confirma que ConfigDir se resuelve al directorio padre del config y que system_prompt_file se puede resolver relativo a el. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,6 +50,47 @@ llm:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── 2.1b: ConfigDir populated from file path ───────────────────────────
|
||||||
|
|
||||||
|
func TestLoad_ConfigDir(t *testing.T) {
|
||||||
|
// Create a nested directory to simulate agents/_specials/father-bot/
|
||||||
|
dir := filepath.Join(t.TempDir(), "agents", "_specials", "father-bot")
|
||||||
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
path := writeYAML(t, dir, "config.yaml", `
|
||||||
|
agent:
|
||||||
|
id: father-bot
|
||||||
|
matrix:
|
||||||
|
homeserver: https://matrix.example.com
|
||||||
|
user_id: "@father-bot:example.com"
|
||||||
|
llm:
|
||||||
|
primary:
|
||||||
|
provider: claude-code
|
||||||
|
claude_code:
|
||||||
|
binary: claude
|
||||||
|
reasoning:
|
||||||
|
system_prompt_file: prompts/system.md
|
||||||
|
`)
|
||||||
|
cfg, err := Load(path)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Load() error: %v", err)
|
||||||
|
}
|
||||||
|
if cfg.ConfigDir != dir {
|
||||||
|
t.Errorf("ConfigDir = %q, want %q", cfg.ConfigDir, dir)
|
||||||
|
}
|
||||||
|
// Verify that joining ConfigDir + system_prompt_file gives the right path
|
||||||
|
spPath := filepath.Join(cfg.ConfigDir, cfg.LLM.Reasoning.SystemPromptFile)
|
||||||
|
wantSuffix := filepath.Join("agents", "_specials", "father-bot", "prompts", "system.md")
|
||||||
|
if !filepath.IsAbs(spPath) {
|
||||||
|
// When running from TempDir, path will be absolute
|
||||||
|
t.Logf("spPath = %q (expected to end with %q)", spPath, wantSuffix)
|
||||||
|
}
|
||||||
|
if cfg.LLM.Reasoning.SystemPromptFile != "prompts/system.md" {
|
||||||
|
t.Errorf("SystemPromptFile = %q, want %q", cfg.LLM.Reasoning.SystemPromptFile, "prompts/system.md")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── 2.2: Parse full config with all sections ────────────────────────────
|
// ── 2.2: Parse full config with all sections ────────────────────────────
|
||||||
|
|
||||||
func TestLoad_FullConfig(t *testing.T) {
|
func TestLoad_FullConfig(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user