From 5ed470a093ffb7d28c88f9687429f238959935da Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 7 Sep 2025 11:49:38 +0300 Subject: test: add seams for RunTUI and client; expand hexaiaction tests; cover lsp initialized and testutil fixtures --- internal/hexaiaction/run.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'internal/hexaiaction/run.go') diff --git a/internal/hexaiaction/run.go b/internal/hexaiaction/run.go index 2a67a58..609dad1 100644 --- a/internal/hexaiaction/run.go +++ b/internal/hexaiaction/run.go @@ -13,15 +13,19 @@ import ( ) // Run executes the hexai-action command flow. +// seams for testability +var chooseActionFn = RunTUI +var newClientFromApp = llmutils.NewClientFromApp + func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error { - logger := log.New(stderr, "hexai-action ", log.LstdFlags|log.Lmsgprefix) - cfg := appconfig.Load(logger) - client, err := llmutils.NewClientFromApp(cfg) - if err != nil { - fmt.Fprintf(stderr, logging.AnsiBase+"hexai-action: LLM disabled: %v"+logging.AnsiReset+"\n", err) - return err - } - parts, err := ParseInput(stdin) + logger := log.New(stderr, "hexai-action ", log.LstdFlags|log.Lmsgprefix) + cfg := appconfig.Load(logger) + client, err := newClientFromApp(cfg) + if err != nil { + fmt.Fprintf(stderr, logging.AnsiBase+"hexai-action: LLM disabled: %v"+logging.AnsiReset+"\n", err) + return err + } + parts, err := ParseInput(stdin) if err != nil { fmt.Fprintln(stderr, logging.AnsiBase+"hexai-action: failed to read input"+logging.AnsiReset) return err @@ -29,10 +33,10 @@ func Run(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error { if strings.TrimSpace(parts.Selection) == "" { return fmt.Errorf("hexai-action: no input provided on stdin") } - kind, err := RunTUI() - if err != nil { - return err - } + kind, err := chooseActionFn() + if err != nil { + return err + } out, err := executeAction(ctx, kind, parts, cfg, client, stderr) if err != nil { return err -- cgit v1.2.3