返回 DeepSeek-Reasonix
recovery_cleanup_test.go
根目录 / internal / config / recovery_cleanup_test.go
1 package config
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7 )
8
9 func TestRecoveryCopyAutoCleanupEnabled(t *testing.T) {
10 cases := []struct {
11 name string
12 content string
13 want bool
14 }{
15 {name: "unset defaults on", content: "", want: true},
16 {name: "explicit on", content: "[recovery_cleanup]\nauto_enabled = true\n", want: true},
17 {name: "explicit off", content: "[recovery_cleanup]\nauto_enabled = false\n", want: false},
18 {name: "unrelated table keeps default", content: "[history_search]\nmax_mb = 64\n", want: true},
19 {name: "malformed keeps default", content: "[recovery_cleanup\n", want: true},
20 }
21 for _, tc := range cases {
22 t.Run(tc.name, func(t *testing.T) {
23 home := t.TempDir()
24 t.Setenv("REASONIX_HOME", home)
25 if tc.content != "" {
26 if err := os.WriteFile(filepath.Join(home, "config.toml"), []byte(tc.content), 0o600); err != nil {
27 t.Fatal(err)
28 }
29 }
30 if got := RecoveryCopyAutoCleanupEnabled(); got != tc.want {
31 t.Fatalf("RecoveryCopyAutoCleanupEnabled() = %v, want %v", got, tc.want)
32 }
33 })
34 }
35 }
36
36 lines GO