diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-07 11:27:43 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-07 11:27:43 +0300 |
| commit | 0d424adfc64da1c61296c66a99162ec68cc4f8d0 (patch) | |
| tree | 2aaaad9e6c5c1886809d213a4bf4f0fe8a5bc3c8 /internal/hexaiaction | |
| parent | 8889949ad3851bfbf36ff5b73128286d67c88201 (diff) | |
hexai-action: integrate tmux orchestration; add internal/tmux; tests+docs; bump version to v0.7.0v0.7.0
Diffstat (limited to 'internal/hexaiaction')
| -rw-r--r-- | internal/hexaiaction/prompts_more_test.go | 19 | ||||
| -rw-r--r-- | internal/hexaiaction/run_more_test.go | 26 |
2 files changed, 45 insertions, 0 deletions
diff --git a/internal/hexaiaction/prompts_more_test.go b/internal/hexaiaction/prompts_more_test.go new file mode 100644 index 0000000..62abc97 --- /dev/null +++ b/internal/hexaiaction/prompts_more_test.go @@ -0,0 +1,19 @@ +package hexaiaction + +import ( + "context" + "strings" + "testing" + + "codeberg.org/snonux/hexai/internal/llm" +) + +type simpleDoer struct{ s string } + +func (d simpleDoer) Chat(_ context.Context, _ []llm.Message, _ ...llm.RequestOption) (string, error) { return d.s, nil } + +func TestRunOnce_StripsFences(t *testing.T) { + got, err := runOnce(context.Background(), simpleDoer{"```\nok\n```"}, "SYS", "USER") + if err != nil { t.Fatalf("runOnce: %v", err) } + if strings.TrimSpace(got) != "ok" { t.Fatalf("got %q", got) } +} diff --git a/internal/hexaiaction/run_more_test.go b/internal/hexaiaction/run_more_test.go new file mode 100644 index 0000000..d7ab025 --- /dev/null +++ b/internal/hexaiaction/run_more_test.go @@ -0,0 +1,26 @@ +package hexaiaction + +import ( + "bytes" + "context" + "os" + "testing" +) + +// Covers the early error path in Run when no API key is available for the default provider. +func TestRun_MissingAPIKey(t *testing.T) { + // Ensure no provider API keys in env + for _, k := range []string{"HEXAI_OPENAI_API_KEY", "OPENAI_API_KEY", "HEXAI_COPILOT_API_KEY", "COPILOT_API_KEY"} { + t.Setenv(k, "") + } + // Provide minimal stdin to get past empty input check (if reached) + in := bytes.NewBufferString("some selection text") + var out bytes.Buffer + var errBuf bytes.Buffer + // Expect an error due to missing OPENAI_API_KEY (default provider is openai) + if err := Run(context.Background(), in, &out, &errBuf); err == nil { + t.Fatal("expected error when API key is missing") + } + _ = os.Stderr +} + |
