diff --git a/internal/config/loader_test.go b/internal/config/loader_test.go index 432d0fe..b4f837e 100644 --- a/internal/config/loader_test.go +++ b/internal/config/loader_test.go @@ -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 ──────────────────────────── func TestLoad_FullConfig(t *testing.T) {