summaryrefslogtreecommitdiff
path: root/internal/hexaiaction/custom_exec_more_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-15 08:07:51 +0300
committerPaul Buetow <paul@buetow.org>2025-09-15 08:07:51 +0300
commitdac90ba0e3036a15779da70e771c5cf2818c817f (patch)
treebd6ddb850a640b3fce79f5e65b27ce41b95e11a3 /internal/hexaiaction/custom_exec_more_test.go
parent828d1cc59ac22d10cd1298aac0488f868e2280db (diff)
release: v0.10.1v0.10.1
- Fix TUI 'p' hotkey: open editor for Custom prompt - Introduce ActionCustomPrompt to disambiguate from Custom actions submenu - Bump version to 0.10.1
Diffstat (limited to 'internal/hexaiaction/custom_exec_more_test.go')
-rw-r--r--internal/hexaiaction/custom_exec_more_test.go71
1 files changed, 38 insertions, 33 deletions
diff --git a/internal/hexaiaction/custom_exec_more_test.go b/internal/hexaiaction/custom_exec_more_test.go
index 657d0d8..de45d26 100644
--- a/internal/hexaiaction/custom_exec_more_test.go
+++ b/internal/hexaiaction/custom_exec_more_test.go
@@ -1,48 +1,53 @@
package hexaiaction
import (
- "context"
- "strings"
- "testing"
+ "context"
+ "strings"
+ "testing"
- "codeberg.org/snonux/hexai/internal/appconfig"
- "codeberg.org/snonux/hexai/internal/llm"
+ "codeberg.org/snonux/hexai/internal/appconfig"
+ "codeberg.org/snonux/hexai/internal/llm"
)
// capDoer captures last LLM messages for assertions.
type capDoer struct{ last []llm.Message }
-func (c *capDoer) Chat(_ context.Context, msgs []llm.Message, _ ...llm.RequestOption) (string, error) { c.last = append([]llm.Message{}, msgs...); return "OK", nil }
+
+func (c *capDoer) Chat(_ context.Context, msgs []llm.Message, _ ...llm.RequestOption) (string, error) {
+ c.last = append([]llm.Message{}, msgs...)
+ return "OK", nil
+}
func (*capDoer) DefaultModel() string { return "m" }
func TestExecuteAction_Custom_ClearsSelection(t *testing.T) {
- cfg := appconfig.Load(nil)
- parts := InputParts{Selection: "code"}
- selectedCustom = &appconfig.CustomAction{ID: "x", Title: "X", Instruction: "Do it"}
- _, _ = executeAction(context.Background(), ActionCustom, parts, cfg, fakeDoer{"OK"}, nil)
- if selectedCustom != nil {
- t.Fatalf("expected selectedCustom cleared after execution")
- }
+ cfg := appconfig.Load(nil)
+ parts := InputParts{Selection: "code"}
+ selectedCustom = &appconfig.CustomAction{ID: "x", Title: "X", Instruction: "Do it"}
+ _, _ = executeAction(context.Background(), ActionCustom, parts, cfg, fakeDoer{"OK"}, nil)
+ if selectedCustom != nil {
+ t.Fatalf("expected selectedCustom cleared after execution")
+ }
}
func TestRunCustom_UserTemplate_InjectsDiagnostics(t *testing.T) {
- cfg := appconfig.Load(nil)
- parts := InputParts{Selection: "code", Diagnostics: []string{"L1", "L2"}}
- ca := appconfig.CustomAction{ID: "y", Title: "Y", User: "{{diagnostics}}\n{{selection}}"}
- cap := &capDoer{}
- _, err := runCustom(context.Background(), cfg, cap, ca, parts)
- if err != nil { t.Fatalf("runCustom error: %v", err) }
- if len(cap.last) == 0 {
- t.Fatalf("expected messages captured")
- }
- // user message should contain diagnostics and selection
- found := false
- for _, m := range cap.last {
- if m.Role == "user" && strings.Contains(m.Content, "L1") && strings.Contains(m.Content, "code") {
- found = true
- }
- }
- if !found {
- t.Fatalf("expected diagnostics and selection in user message: %+v", cap.last)
- }
+ cfg := appconfig.Load(nil)
+ parts := InputParts{Selection: "code", Diagnostics: []string{"L1", "L2"}}
+ ca := appconfig.CustomAction{ID: "y", Title: "Y", User: "{{diagnostics}}\n{{selection}}"}
+ cap := &capDoer{}
+ _, err := runCustom(context.Background(), cfg, cap, ca, parts)
+ if err != nil {
+ t.Fatalf("runCustom error: %v", err)
+ }
+ if len(cap.last) == 0 {
+ t.Fatalf("expected messages captured")
+ }
+ // user message should contain diagnostics and selection
+ found := false
+ for _, m := range cap.last {
+ if m.Role == "user" && strings.Contains(m.Content, "L1") && strings.Contains(m.Content, "code") {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatalf("expected diagnostics and selection in user message: %+v", cap.last)
+ }
}
-