summaryrefslogtreecommitdiff
path: root/internal/runtimeconfig/store_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
committerPaul Buetow <paul@buetow.org>2025-09-26 07:52:08 +0300
commit2efcd2c4dda97831058851e8911281d5db5ce1c6 (patch)
treec59059cb4c781878f1291ca06fe1a215579a0fa8 /internal/runtimeconfig/store_test.go
parentd0330d02ff040326216ab940a767490cb2de09ce (diff)
Log config reload changes
Diffstat (limited to 'internal/runtimeconfig/store_test.go')
-rw-r--r--internal/runtimeconfig/store_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/runtimeconfig/store_test.go b/internal/runtimeconfig/store_test.go
index 9973a1a..6e40c76 100644
--- a/internal/runtimeconfig/store_test.go
+++ b/internal/runtimeconfig/store_test.go
@@ -1,10 +1,12 @@
package runtimeconfig
import (
+ "bytes"
"io"
"log"
"os"
"path/filepath"
+ "strings"
"testing"
"codeberg.org/snonux/hexai/internal/appconfig"
@@ -57,3 +59,38 @@ func TestStoreReloadSkipsEnvOverrides(t *testing.T) {
t.Fatalf("expected max_tokens change in diff, got %#v", changes)
}
}
+
+func TestStoreReloadLogsSummary(t *testing.T) {
+ var buf bytes.Buffer
+ logger := log.New(&buf, "", 0)
+ tmp := t.TempDir()
+ configDir := filepath.Join(tmp, "hexai")
+ if err := os.MkdirAll(configDir, 0o755); err != nil {
+ t.Fatalf("mkdir: %v", err)
+ }
+ configPath := filepath.Join(configDir, "config.toml")
+ if err := os.WriteFile(configPath, []byte("[general]\nmax_tokens = 64\n"), 0o644); err != nil {
+ t.Fatalf("write config: %v", err)
+ }
+
+ t.Setenv("XDG_CONFIG_HOME", tmp)
+ t.Setenv("HEXAI_MAX_TOKENS", "321")
+
+ initial := appconfig.Load(logger)
+ store := New(initial)
+ if err := os.WriteFile(configPath, []byte("[general]\nmax_tokens = 128\n"), 0o644); err != nil {
+ t.Fatalf("update config: %v", err)
+ }
+
+ _, err := store.Reload(logger, appconfig.LoadOptions{IgnoreEnv: true})
+ if err != nil {
+ t.Fatalf("reload failed: %v", err)
+ }
+ logOutput := buf.String()
+ if !strings.Contains(logOutput, "Reloaded config (1 changes):") {
+ t.Fatalf("expected summary line in log, got %q", logOutput)
+ }
+ if !strings.Contains(logOutput, "- max_tokens: 321 → 128") {
+ t.Fatalf("expected change details in log, got %q", logOutput)
+ }
+}