返回 DeepSeek-Reasonix
doctor_repair_test.go
根目录 / internal / cli / doctor_repair_test.go
1 package cli
2
3 import (
4 "os"
5 "path/filepath"
6 "testing"
7 )
8
9 func TestDoctorRepairSkipsConfigStartupMutation(t *testing.T) {
10 if !isDoctorRepairCommand([]string{"doctor", "repair", "--json"}) {
11 t.Fatal("doctor repair was not recognized")
12 }
13 for _, args := range [][]string{{"doctor"}, {"doctor", "capabilities"}, {"run"}} {
14 if isDoctorRepairCommand(args) {
15 t.Fatalf("unexpected repair match for %v", args)
16 }
17 }
18 }
19
20 func TestDoctorRepairDryRunDoesNotMigrateConfig(t *testing.T) {
21 home := t.TempDir()
22 root := t.TempDir()
23 t.Setenv("REASONIX_HOME", home)
24 path := filepath.Join(root, "reasonix.toml")
25 body := []byte("[[plugins]]\nname = \"legacy\"\ncommand = \"legacy\"\ntier = \"lazy\"\n")
26 if err := os.WriteFile(path, body, 0o600); err != nil {
27 t.Fatal(err)
28 }
29 if code := Run([]string{"doctor", "repair", "--root", root, "--json"}, "test"); code != 0 {
30 t.Fatalf("exit code = %d", code)
31 }
32 got, err := os.ReadFile(path)
33 if err != nil {
34 t.Fatal(err)
35 }
36 if string(got) != string(body) {
37 t.Fatalf("dry run changed config:\n%s", got)
38 }
39 }
40
40 lines GO