diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-19 22:52:48 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-19 22:52:48 +0300 |
| commit | eb72b06fe8e62cb77af73f6dc558d384a5a5fe80 (patch) | |
| tree | efeb1165b9fbcb69a4ee675dba7bdc8c28fee3aa /internal/hexaicli/run_test.go | |
| parent | acc400768153a7bfda1413f15579c9455b877c87 (diff) | |
fix
Diffstat (limited to 'internal/hexaicli/run_test.go')
| -rw-r--r-- | internal/hexaicli/run_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/hexaicli/run_test.go b/internal/hexaicli/run_test.go index d192850..a4184f6 100644 --- a/internal/hexaicli/run_test.go +++ b/internal/hexaicli/run_test.go @@ -12,6 +12,10 @@ import ( "codeberg.org/snonux/hexai/internal/llm" ) +type failingReader struct{ err error } + +func (f failingReader) Read([]byte) (int, error) { return 0, f.err } + func TestReadInput_Combinations(t *testing.T) { // stdin + arg restore, f := setStdin(t, "from-stdin") @@ -41,6 +45,15 @@ func TestReadInput_Combinations(t *testing.T) { } } +func TestReadInput_PropagatesStdinError(t *testing.T) { + restore, _ := setStdin(t, "ignored") + defer restore() + bad := failingReader{err: io.ErrUnexpectedEOF} + if _, err := readInput(bad, nil); err == nil || !strings.Contains(err.Error(), "failed to read stdin") { + t.Fatalf("expected stdin read error, got %v", err) + } +} + func TestBuildMessages_Explain(t *testing.T) { msgs := buildMessages("please explain this") if len(msgs) != 2 || msgs[0].Role != "system" || !strings.Contains(strings.ToLower(msgs[0].Content), "explanation") { |
