diff options
Diffstat (limited to 'internal/hexaiaction/run_seam_test.go')
| -rw-r--r-- | internal/hexaiaction/run_seam_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/hexaiaction/run_seam_test.go b/internal/hexaiaction/run_seam_test.go index affd68e..8fb8533 100644 --- a/internal/hexaiaction/run_seam_test.go +++ b/internal/hexaiaction/run_seam_test.go @@ -3,6 +3,7 @@ package hexaiaction import ( "bytes" "context" + "log" "testing" "codeberg.org/snonux/hexai/internal/appconfig" @@ -17,6 +18,17 @@ func (llmFake) Chat(_ context.Context, _ []llm.Message, _ ...llm.RequestOption) func (llmFake) Name() string { return "fake" } func (llmFake) DefaultModel() string { return "model" } +type recordingActionStatusSink struct { + provider string + model string +} + +func (s *recordingActionStatusSink) SetLLMStart(provider, model string) error { + s.provider = provider + s.model = model + return nil +} + func TestRun_WithSeams_SkipAndRewrite(t *testing.T) { // Isolate from user config to avoid environment-dependent behavior/logging. t.Setenv("XDG_CONFIG_HOME", t.TempDir()) @@ -48,3 +60,26 @@ func TestRun_WithSeams_SkipAndRewrite(t *testing.T) { t.Fatalf("expected non-empty rewrite output") } } + +func TestRun_WithInjectedConfigAndStatusSink(t *testing.T) { + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + sink := &recordingActionStatusSink{} + runner := NewRunner() + runner.loadConfig = func(context.Context, *log.Logger) appconfig.App { return appconfig.Load(nil) } + runner.newClient = func(_ appconfig.App) (actionClient, error) { return llmFake{}, nil } + runner.chooseAction = func(_ appconfig.App) (actionChoice, error) { + return actionChoice{kind: ActionSkip}, nil + } + runner.statusSink = sink + + var out bytes.Buffer + if err := runner.Run(context.Background(), bytes.NewBufferString("selection"), &out, &bytes.Buffer{}); err != nil { + t.Fatalf("Run: %v", err) + } + if out.String() != "selection" { + t.Fatalf("unexpected output %q", out.String()) + } + if sink.provider != "fake" || sink.model == "" { + t.Fatalf("unexpected status sink values: provider=%q model=%q", sink.provider, sink.model) + } +} |
