From eb72b06fe8e62cb77af73f6dc558d384a5a5fe80 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 19 Sep 2025 22:52:48 +0300 Subject: fix --- internal/hexaicli/run_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'internal/hexaicli/run_test.go') 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") { -- cgit v1.2.3