diff options
Diffstat (limited to 'internal/appconfig/config_test.go')
| -rw-r--r-- | internal/appconfig/config_test.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/internal/appconfig/config_test.go b/internal/appconfig/config_test.go index 5cb79a0..dc8c39c 100644 --- a/internal/appconfig/config_test.go +++ b/internal/appconfig/config_test.go @@ -25,15 +25,15 @@ func writeFile(t *testing.T, path, content string) { // clearHexaiEnv removes any HEXAI_* variables to prevent environment leakage // into tests that expect file-only configuration. func clearHexaiEnv(t *testing.T) { - t.Helper() - for _, e := range os.Environ() { - if strings.HasPrefix(e, "HEXAI_") { - kv := strings.SplitN(e, "=", 2) - if len(kv) > 0 { - t.Setenv(kv[0], "") - } - } - } + t.Helper() + for _, e := range os.Environ() { + if strings.HasPrefix(e, "HEXAI_") { + kv := strings.SplitN(e, "=", 2) + if len(kv) > 0 { + t.Setenv(kv[0], "") + } + } + } } func withEnv(t *testing.T, k, v string) { @@ -54,10 +54,10 @@ func TestLoad_Defaults_NoLogger(t *testing.T) { } func TestLoad_Defaults_WithLogger_NoFile_NoEnv(t *testing.T) { - clearHexaiEnv(t) - t.Setenv("XDG_CONFIG_HOME", t.TempDir()) - logger := newLogger() - cfg := Load(logger) + clearHexaiEnv(t) + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + logger := newLogger() + cfg := Load(logger) def := newDefaultConfig() if cfg.MaxTokens != def.MaxTokens || cfg.ContextMode != def.ContextMode || cfg.ContextWindowLines != def.ContextWindowLines { t.Fatalf("expected defaults; got %+v want %+v", cfg, def) @@ -207,9 +207,9 @@ func TestLoadFromFile_InvalidTOML(t *testing.T) { } func TestLoad_FileTables_Sectioned(t *testing.T) { - clearHexaiEnv(t) - dir := t.TempDir() - t.Setenv("XDG_CONFIG_HOME", dir) + clearHexaiEnv(t) + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) cfgPath := filepath.Join(dir, "hexai", "config.toml") content := ` [general] @@ -290,9 +290,9 @@ temperature = 0.0 } func TestLoad_FileTables_Prompts_AllSections(t *testing.T) { - clearHexaiEnv(t) - dir := t.TempDir() - t.Setenv("XDG_CONFIG_HOME", dir) + clearHexaiEnv(t) + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) cfgPath := filepath.Join(dir, "hexai", "config.toml") content := ` [prompts.completion] |
