Validate that Universal.JumpToBlock array has 5 elements

The code that uses this panics if it has fewer.
This commit is contained in:
Stefan Haller 2025-02-16 16:45:28 +01:00
parent f3791e6ab6
commit a5f78d3222
2 changed files with 24 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package config
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -42,6 +43,19 @@ func TestUserConfigValidate_enums(t *testing.T) {
{value: "invalid_value", valid: false},
},
},
{
name: "JumpToBlock keybinding",
setup: func(config *UserConfig, value string) {
config.Keybinding.Universal.JumpToBlock = strings.Split(value, ",")
},
testCases: []testCase{
{value: "", valid: false},
{value: "1,2,3", valid: false},
{value: "1,2,3,4,5", valid: true},
{value: "1,2,3,4,invalid", valid: false},
{value: "1,2,3,4,5,6", valid: false},
},
},
}
for _, s := range scenarios {