Skip to content

Commit 3575bb9

Browse files
committed
Add enum validation for Git.Log.Order and Git.Log.ShowGraph
1 parent 562a2aa commit 3575bb9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pkg/config/user_config_validation.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ func (config *UserConfig) Validate() error {
3131
[]string{"date", "alphabetical"}); err != nil {
3232
return err
3333
}
34+
if err := validateEnum("git.log.order", config.Git.Log.Order,
35+
[]string{"date-order", "author-date-order", "topo-order", "default"}); err != nil {
36+
return err
37+
}
38+
if err := validateEnum("git.log.showGraph", config.Git.Log.ShowGraph,
39+
[]string{"always", "never", "when-maximised"}); err != nil {
40+
return err
41+
}
3442
if err := validateKeybindings(config.Keybinding); err != nil {
3543
return err
3644
}

pkg/config/user_config_validation_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,35 @@ func TestUserConfigValidate_enums(t *testing.T) {
8282
{value: "invalid_value", valid: false},
8383
},
8484
},
85+
{
86+
name: "Git.Log.Order",
87+
setup: func(config *UserConfig, value string) {
88+
config.Git.Log.Order = value
89+
},
90+
testCases: []testCase{
91+
{value: "date-order", valid: true},
92+
{value: "author-date-order", valid: true},
93+
{value: "topo-order", valid: true},
94+
{value: "default", valid: true},
95+
96+
{value: "", valid: false},
97+
{value: "invalid_value", valid: false},
98+
},
99+
},
100+
{
101+
name: "Git.Log.ShowGraph",
102+
setup: func(config *UserConfig, value string) {
103+
config.Git.Log.ShowGraph = value
104+
},
105+
testCases: []testCase{
106+
{value: "always", valid: true},
107+
{value: "never", valid: true},
108+
{value: "when-maximised", valid: true},
109+
110+
{value: "", valid: false},
111+
{value: "invalid_value", valid: false},
112+
},
113+
},
85114
{
86115
name: "Keybindings",
87116
setup: func(config *UserConfig, value string) {

0 commit comments

Comments
 (0)