diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-14 23:40:26 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-14 23:40:26 +0300 |
| commit | f4470bbcfbe3b14c99baeef475fe872825a13a39 (patch) | |
| tree | e12fc6168d21119dfff3a0fef5b6c5b54149f3ab /internal/appconfig/custom_validation_more_test.go | |
| parent | 68438c98d23545ff791768e3e219cd21d3814e0c (diff) | |
release: v0.10.0v0.10.0
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) + } +} + |
