返回 DeepSeek-Reasonix
settings_shadow_test.go
根目录 / desktop / settings_shadow_test.go
1 package main
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7 )
8
9 func TestShadowingConfigPathReportsProjectFile(t *testing.T) {
10 home := t.TempDir()
11 t.Setenv("REASONIX_HOME", home)
12 userPath := filepath.Join(home, "config.toml")
13 if err := os.WriteFile(userPath, []byte("default_model = \"a\"\n"), 0o600); err != nil {
14 t.Fatal(err)
15 }
16 root := t.TempDir()
17 project := filepath.Join(root, "reasonix.toml")
18 if err := os.WriteFile(project, []byte("default_model = \"b\"\n"), 0o600); err != nil {
19 t.Fatal(err)
20 }
21
22 got := shadowingConfigPath(userPath, root)
23 if !samePath(got, project) {
24 t.Fatalf("shadowingConfigPath = %q, want the project file %q", got, project)
25 }
26 }
27
28 func TestShadowingConfigPathEmptyWhenUserConfigWins(t *testing.T) {
29 home := t.TempDir()
30 t.Setenv("REASONIX_HOME", home)
31 userPath := filepath.Join(home, "config.toml")
32 if err := os.WriteFile(userPath, []byte("default_model = \"a\"\n"), 0o600); err != nil {
33 t.Fatal(err)
34 }
35
36 if got := shadowingConfigPath(userPath, t.TempDir()); got != "" {
37 t.Fatalf("shadowingConfigPath = %q, want empty when the panel writes the effective file", got)
38 }
39 }
40
40 lines GO