From 1bc98813fc029ff111ed2db2bc5833737e193b6f Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 1 Oct 2026 16:42:40 +0200 Subject: [PATCH] test(web): read the response body once; match the message's real case Two defects in my red tests, found when going green: body() drains the recorder so a second call read empty, and two assertions expected a different case than the user-facing message. The assertions were not weakened. Co-Authored-By: Claude Sonnet 5.5 --- internal/web/uploads_handler_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/web/uploads_handler_test.go b/internal/web/uploads_handler_test.go index 2914e2c..c43e982 100644 --- a/internal/web/uploads_handler_test.go +++ b/internal/web/uploads_handler_test.go @@ -189,8 +189,9 @@ func TestUploadPost_RejectionsAreSynchronousWithAMessageAndNoRow(t *testing.T) { rec := do(t, app, uploadReq(t, "t", "r.m4a", []byte(tt.content))) assert.Equal(t, tt.wantStatus, rec.Code) + b := body(t, rec) for _, s := range tt.wantInBody { - assert.Contains(t, body(t, rec), s) + assert.Contains(t, b, s) } var n int require.NoError(t, rawPool(t).QueryRow(context.Background(), @@ -207,7 +208,7 @@ func TestUploadPost_WithNoFilePartIs400(t *testing.T) { rec := do(t, app, uploadReq(t, "only a title", "", nil)) assert.Equal(t, http.StatusBadRequest, rec.Code) - assert.Contains(t, body(t, rec), "choose") + assert.Contains(t, body(t, rec), "Choose an audio file") } func TestUploadRoutes_AreNotMountedWithoutAnUploader(t *testing.T) { @@ -240,7 +241,7 @@ func TestUploadStatus_UnfinishedStatesKeepPollingTerminalStatesStop(t *testing.T polls bool wantInBody string }{ - {"queued", "queued", "", true, "queued"}, + {"queued", "queued", "", true, "Queued"}, {"transcribing", "transcribing", "", true, "ranscrib"}, {"done", "done", "Synthetic transcript text.", false, "Synthetic transcript text."}, {"failed interrupted", "failed", "interrupted", false, "upload it again"},