mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
UserConfig validation
This commit is contained in:
parent
2b5c814080
commit
5c3aacb4cb
3 changed files with 75 additions and 0 deletions
49
pkg/config/user_config_validation_test.go
Normal file
49
pkg/config/user_config_validation_test.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestUserConfigValidate_enums(t *testing.T) {
|
||||
type testCase struct {
|
||||
value string
|
||||
valid bool
|
||||
}
|
||||
|
||||
scenarios := []struct {
|
||||
name string
|
||||
setup func(config *UserConfig, value string)
|
||||
testCases []testCase
|
||||
}{
|
||||
{
|
||||
name: "Gui.StatusPanelView",
|
||||
setup: func(config *UserConfig, value string) {
|
||||
config.Gui.StatusPanelView = value
|
||||
},
|
||||
testCases: []testCase{
|
||||
{value: "dashboard", valid: true},
|
||||
{value: "allBranchesLog", valid: true},
|
||||
{value: "", valid: false},
|
||||
{value: "invalid_value", valid: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
t.Run(s.name, func(t *testing.T) {
|
||||
for _, testCase := range s.testCases {
|
||||
config := GetDefaultConfig()
|
||||
s.setup(config, testCase.value)
|
||||
err := config.Validate()
|
||||
|
||||
if testCase.valid {
|
||||
assert.NoError(t, err)
|
||||
} else {
|
||||
assert.Error(t, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue