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 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,8 @@ type wStore struct {
|
|||||||
completed map[string]domain.Transcription
|
completed map[string]domain.Transcription
|
||||||
failed map[string]domain.UploadErrorKind
|
failed map[string]domain.UploadErrorKind
|
||||||
startErr error
|
startErr error
|
||||||
|
// completeErr makes CompleteUpload fail, as a database outage would.
|
||||||
|
completeErr error
|
||||||
saves [][]domain.ProgressStep
|
saves [][]domain.ProgressStep
|
||||||
beats int
|
beats int
|
||||||
// beatDelay makes each heartbeat write slow, so one is still in flight when a job
|
// beatDelay makes each heartbeat write slow, so one is still in flight when a job
|
||||||
@@ -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 {
|
func (s *wStore) CompleteUpload(_ context.Context, _, id string, t domain.Transcription) error {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
defer s.mu.Unlock()
|
defer s.mu.Unlock()
|
||||||
|
if s.completeErr != nil {
|
||||||
|
return s.completeErr
|
||||||
|
}
|
||||||
s.completed[id] = t
|
s.completed[id] = t
|
||||||
return nil
|
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") }},
|
{"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") }},
|
{"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 {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user