blob: 1f9ac2dec793bcdd08b5e5ef1cf5ab1dffc6b6d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package appconfig
import (
"reflect"
"testing"
)
// buildFeatureApp returns an App whose FeatureConfig subsystems are all
// populated, used to verify the fine-grained section accessors.
func buildFeatureApp() App {
cfg := App{}
cfg.ApplyFeatureSection(testFeatureConfig())
return cfg
}
func TestIgnoreSectionCopiesAndReads(t *testing.T) {
cfg := buildFeatureApp()
got := cfg.IgnoreSection()
if !reflect.DeepEqual(got.IgnoreExtraPatterns, []string{"vendor/**", "tmp/**"}) {
t.Fatalf("IgnoreExtraPatterns = %v", got.IgnoreExtraPatterns)
}
// Mutating the returned copy must not affect the source App.
got.IgnoreExtraPatterns[0] = "mutated"
if cfg.IgnoreExtraPatterns[0] == "mutated" {
t.Fatal("IgnoreSection did not return a defensive copy")
}
}
func TestStatsSectionReads(t *testing.T) {
cfg := buildFeatureApp()
if got := cfg.StatsSection(); got.StatsWindowMinutes != 15 {
t.Fatalf("StatsWindowMinutes = %d, want 15", got.StatsWindowMinutes)
}
}
func TestTmuxEditSectionCopies(t *testing.T) {
cfg := buildFeatureApp()
got := cfg.TmuxEditSection()
if got.TmuxEditDefaultAgent != "codex" || len(got.TmuxEditAgents) != 1 {
t.Fatalf("unexpected tmux edit section: %+v", got)
}
got.TmuxEditAgents[0].Name = "mutated"
if cfg.TmuxEditAgents[0].Name == "mutated" {
t.Fatal("TmuxEditSection did not return a defensive copy")
}
}
func TestTmuxActionSectionCopies(t *testing.T) {
cfg := App{}
cfg.TmuxActionMenu = []TmuxActionMenuEntry{{Kind: "rewrite"}}
got := cfg.TmuxActionSection()
if len(got.TmuxActionMenu) != 1 || got.TmuxActionMenu[0].Kind != "rewrite" {
t.Fatalf("unexpected tmux action section: %+v", got)
}
got.TmuxActionMenu[0].Kind = "mutated"
if cfg.TmuxActionMenu[0].Kind == "mutated" {
t.Fatal("TmuxActionSection did not return a defensive copy")
}
}
func TestMCPSectionReads(t *testing.T) {
cfg := buildFeatureApp()
got := cfg.MCPSection()
if got.MCPPromptsDir != ".hexai/prompts" || !got.MCPSlashCommandSync ||
got.MCPSlashCommandDir != ".hexai/slash" {
t.Fatalf("unexpected MCP section: %+v", got)
}
}
|