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 <noreply@anthropic.com>
This commit is contained in:
@@ -189,8 +189,9 @@ func TestUploadPost_RejectionsAreSynchronousWithAMessageAndNoRow(t *testing.T) {
|
|||||||
rec := do(t, app, uploadReq(t, "t", "r.m4a", []byte(tt.content)))
|
rec := do(t, app, uploadReq(t, "t", "r.m4a", []byte(tt.content)))
|
||||||
|
|
||||||
assert.Equal(t, tt.wantStatus, rec.Code)
|
assert.Equal(t, tt.wantStatus, rec.Code)
|
||||||
|
b := body(t, rec)
|
||||||
for _, s := range tt.wantInBody {
|
for _, s := range tt.wantInBody {
|
||||||
assert.Contains(t, body(t, rec), s)
|
assert.Contains(t, b, s)
|
||||||
}
|
}
|
||||||
var n int
|
var n int
|
||||||
require.NoError(t, rawPool(t).QueryRow(context.Background(),
|
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))
|
rec := do(t, app, uploadReq(t, "only a title", "", nil))
|
||||||
|
|
||||||
assert.Equal(t, http.StatusBadRequest, rec.Code)
|
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) {
|
func TestUploadRoutes_AreNotMountedWithoutAnUploader(t *testing.T) {
|
||||||
@@ -240,7 +241,7 @@ func TestUploadStatus_UnfinishedStatesKeepPollingTerminalStatesStop(t *testing.T
|
|||||||
polls bool
|
polls bool
|
||||||
wantInBody string
|
wantInBody string
|
||||||
}{
|
}{
|
||||||
{"queued", "queued", "", true, "queued"},
|
{"queued", "queued", "", true, "Queued"},
|
||||||
{"transcribing", "transcribing", "", true, "ranscrib"},
|
{"transcribing", "transcribing", "", true, "ranscrib"},
|
||||||
{"done", "done", "Synthetic transcript text.", false, "Synthetic transcript text."},
|
{"done", "done", "Synthetic transcript text.", false, "Synthetic transcript text."},
|
||||||
{"failed interrupted", "failed", "interrupted", false, "upload it again"},
|
{"failed interrupted", "failed", "interrupted", false, "upload it again"},
|
||||||
|
|||||||
Reference in New Issue
Block a user