summaryrefslogtreecommitdiff
path: root/internal/hexaiaction/run_seam_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-02 14:54:08 +0200
committerPaul Buetow <paul@buetow.org>2026-03-02 14:54:08 +0200
commitf80462176d1ad0daf20b05d6410074369148c245 (patch)
tree5cbe412797c923a881333bd89d59d238be646ad7 /internal/hexaiaction/run_seam_test.go
parent5f8e008fc2e5a9abb8bc2c8cfe66ec49cce3a19d (diff)
hexaiaction: replace global action state with Runner struct (task 406)
Diffstat (limited to 'internal/hexaiaction/run_seam_test.go')
-rw-r--r--internal/hexaiaction/run_seam_test.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/internal/hexaiaction/run_seam_test.go b/internal/hexaiaction/run_seam_test.go
index 9aa92bf..affd68e 100644
--- a/internal/hexaiaction/run_seam_test.go
+++ b/internal/hexaiaction/run_seam_test.go
@@ -20,27 +20,28 @@ func (llmFake) DefaultModel() string { return "model" }
func TestRun_WithSeams_SkipAndRewrite(t *testing.T) {
// Isolate from user config to avoid environment-dependent behavior/logging.
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
- // Seam: choose action to Skip first, then Rewrite
- oldChoose := chooseActionFn
- oldNew := newClientFromApp
- t.Cleanup(func() { chooseActionFn = oldChoose; newClientFromApp = oldNew })
+ runner := NewRunner()
+ runner.newClient = func(_ appconfig.App) (actionClient, error) { return llmFake{}, nil }
// 1) Skip -> echoes selection
- chooseActionFn = func() (ActionKind, error) { return ActionSkip, nil }
- newClientFromApp = func(_ appconfig.App) (llm.Client, error) { return llmFake{}, nil }
+ runner.chooseAction = func(_ appconfig.App) (actionChoice, error) {
+ return actionChoice{kind: ActionSkip}, nil
+ }
var out bytes.Buffer
var errBuf bytes.Buffer
in := bytes.NewBufferString("some code")
- if err := Run(context.Background(), in, &out, &errBuf); err != nil {
+ if err := runner.Run(context.Background(), in, &out, &errBuf); err != nil {
t.Fatalf("Run skip: %v", err)
}
if out.String() != "some code" {
t.Fatalf("skip out: %q", out.String())
}
// 2) Rewrite -> requires inline instruction
- chooseActionFn = func() (ActionKind, error) { return ActionRewrite, nil }
+ runner.chooseAction = func(_ appconfig.App) (actionChoice, error) {
+ return actionChoice{kind: ActionRewrite}, nil
+ }
out.Reset()
in = bytes.NewBufferString(";upper;\nhello")
- if err := Run(context.Background(), in, &out, &errBuf); err != nil {
+ if err := runner.Run(context.Background(), in, &out, &errBuf); err != nil {
t.Fatalf("Run rewrite: %v", err)
}
if out.String() == "" {