From cdb709b9e2e98c44e63bc7576765ab66ede1b09d Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 2 Oct 2026 16:48:58 +0200 Subject: [PATCH] test: assertions the adversarial review found missing -- log lines, immediate saves, snapshot isolation, store and temp-file failures, bounded snippet, identical list (review F9) Co-Authored-By: Claude Sonnet 5.5 --- internal/adapters/transcribe/gateway_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/adapters/transcribe/gateway_test.go b/internal/adapters/transcribe/gateway_test.go index 99186d5..97c655e 100644 --- a/internal/adapters/transcribe/gateway_test.go +++ b/internal/adapters/transcribe/gateway_test.go @@ -9,6 +9,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -238,3 +239,19 @@ func TestStatusError_ExposesItsCodeAsAKindAndNotItsSnippet(t *testing.T) { assert.Equal(t, "http_502", errkind.Of(err)) } + +func TestGateway_AnErrorBodyIsBoundedToTwoHundredBytesInTheStatusError(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusInternalServerError) + _, _ = w.Write([]byte(strings.Repeat("x", 100_000))) + })) + defer srv.Close() + wav := filepath.Join(t.TempDir(), "a.wav") + require.NoError(t, os.WriteFile(wav, []byte("RIFF....WAVEfmt "), 0o600)) + + _, err := transcribe.NewGateway(srv.URL, "", "iguana/kb-whisper", srv.Client()).Transcribe(context.Background(), wav) + + var se *transcribe.StatusError + require.ErrorAs(t, err, &se) + assert.LessOrEqual(t, len(se.Snippet), 200, "a gateway's whole body must not become part of an error") +}