diff options
Diffstat (limited to 'internal/appconfig/custom_validation_more_test.go')
| -rw-r--r-- | internal/appconfig/custom_validation_more_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/internal/appconfig/custom_validation_more_test.go b/internal/appconfig/custom_validation_more_test.go new file mode 100644 index 0000000..05d0d1a --- /dev/null +++ b/internal/appconfig/custom_validation_more_test.go @@ -0,0 +1,48 @@ +package appconfig + +import ( + "path/filepath" + "strings" + "testing" +) + +func TestCustomActions_MissingFields(t *testing.T) { + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) + cfgPath := filepath.Join(dir, "hexai", "config.toml") + writeFile(t, cfgPath, ` +[prompts.code_action] +[[prompts.code_action.custom]] +title = "No ID" +instruction = "x" +[[prompts.code_action.custom]] +id = "no-title" +instruction = "x" +`) + cfg := Load(newLogger()) + if err := cfg.Validate(); err == nil || (!strings.Contains(err.Error(), "missing required field id") && !strings.Contains(err.Error(), "missing required field title")) { + t.Fatalf("expected missing field error, got %v", err) + } +} + +func TestCustomActions_InvalidHotkeys(t *testing.T) { + dir := t.TempDir() + t.Setenv("XDG_CONFIG_HOME", dir) + cfgPath := filepath.Join(dir, "hexai", "config.toml") + writeFile(t, cfgPath, ` +[prompts.code_action] +[[prompts.code_action.custom]] +id = "a" +title = "A" +instruction = "x" +hotkey = "too" + +[tmux] +custom_menu_hotkey = "ab" +`) + cfg := Load(newLogger()) + if err := cfg.Validate(); err == nil || (!strings.Contains(err.Error(), "hotkey must be a single character") && !strings.Contains(err.Error(), "invalid tmux.custom_menu_hotkey")) { + t.Fatalf("expected invalid hotkey error, got %v", err) + } +} + |
