summaryrefslogtreecommitdiff
path: root/internal/hexaicli/run_editor_behavior_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/hexaicli/run_editor_behavior_test.go')
-rw-r--r--internal/hexaicli/run_editor_behavior_test.go17
1 files changed, 5 insertions, 12 deletions
diff --git a/internal/hexaicli/run_editor_behavior_test.go b/internal/hexaicli/run_editor_behavior_test.go
index 99a2f2d..b9ebd75 100644
--- a/internal/hexaicli/run_editor_behavior_test.go
+++ b/internal/hexaicli/run_editor_behavior_test.go
@@ -7,7 +7,6 @@ import (
"testing"
"codeberg.org/snonux/hexai/internal/appconfig"
- "codeberg.org/snonux/hexai/internal/editor"
"codeberg.org/snonux/hexai/internal/llm"
)
@@ -22,23 +21,17 @@ func (okClient) DefaultModel() string { return "m" }
// Ensure that when stdin has content and args are empty, Run does not open the editor.
func TestRun_DoesNotOpenEditorWhenStdinPresent(t *testing.T) {
- // Guard: make editor invocation fatal if called
- oldRunEd := editor.RunEditor
- defer func() { editor.RunEditor = oldRunEd }()
- editor.RunEditor = func(_ context.Context, _ string, _ string) error {
+ runner := NewRunner()
+ runner.openEditor = func(context.Context, []byte) (string, error) {
t.Fatalf("editor should not be invoked when stdin has content")
- return nil
+ return "", nil
}
-
- // Stub client constructor to avoid hitting real providers
- oldNew := newClientFromApp
- defer func() { newClientFromApp = oldNew }()
- newClientFromApp = func(_ appconfig.App) (llm.Client, error) { return okClient{}, nil }
+ runner.newClient = func(_ appconfig.App) (llm.Client, error) { return okClient{}, nil }
var out, errb bytes.Buffer
restore, f := setStdin(t, "from-stdin")
defer restore()
- if err := Run(context.Background(), nil, f, &out, &errb); err != nil {
+ if err := runner.Run(context.Background(), nil, f, &out, &errb); err != nil {
t.Fatalf("Run: %v", err)
}
if !strings.Contains(out.String(), "OK") {