From 5b3e550d9b511908bf2c824bd54377549ed20e03 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/uploads/worker_test.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/internal/uploads/worker_test.go b/internal/uploads/worker_test.go index e8abbf7..253501c 100644 --- a/internal/uploads/worker_test.go +++ b/internal/uploads/worker_test.go @@ -23,8 +23,10 @@ type wStore struct { completed map[string]domain.Transcription failed map[string]domain.UploadErrorKind startErr error - saves [][]domain.ProgressStep - beats int + // completeErr makes CompleteUpload fail, as a database outage would. + completeErr error + saves [][]domain.ProgressStep + beats int // beatDelay makes each heartbeat write slow, so one is still in flight when a job // ends -- which is what proves the worker waits for its heartbeat to finish. beatDelay time.Duration @@ -44,6 +46,9 @@ func (s *wStore) StartTranscribing(_ context.Context, _, id string) error { func (s *wStore) CompleteUpload(_ context.Context, _, id string, t domain.Transcription) error { s.mu.Lock() defer s.mu.Unlock() + if s.completeErr != nil { + return s.completeErr + } s.completed[id] = t return nil } @@ -208,6 +213,10 @@ func TestWorkerProcess_FailuresAreTypedAndStillDeleteTheAudio(t *testing.T) { }{ {"conversion fails", func(r *wrig) { r.conv.err = errors.New("moov atom not found") }}, {"every transcription endpoint fails", func(r *wrig) { r.tr.err = errors.New("iguana down; berget down") }}, + {"storing the finished transcript fails", func(r *wrig) { r.st.completeErr = errors.New("db down") }}, + {"the temporary WAV cannot be created", func(r *wrig) { + r.w = uploads.NewWorker(r.st, r.conv, r.tr, filepath.Join(r.tmp, "missing"), time.Minute) + }}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {