Form field (Swedish preselected, Other = auto) read before the file part and refused before anything is spooled if outside the closed set; stored on the row (migration 021, CHECK constraint, default sv for history); carried on the Job and the worker's context; shown on the status page. Feature scenarios and the coverage map are updated, and ADR-033/034 amended. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package store_test
|
|
|
|
// A shutdown can record a job as failed after its transcript was already committed (the
|
|
// commit lands, the caller sees a cancelled context). FailUpload must not be able to turn a
|
|
// finished row into a failed one and hide the text (#50 review).
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"git.d-ma.be/mathias/tapir/internal/domain"
|
|
)
|
|
|
|
func TestFailUpload_LeavesAFinishedUploadAsItWas(t *testing.T) {
|
|
s := newStore(t)
|
|
ctx := context.Background()
|
|
id := startedUpload(t, s)
|
|
require.NoError(t, s.StartTranscribing(ctx, userA, id))
|
|
require.NoError(t, s.CompleteUpload(ctx, userA, id, domain.Transcription{Text: "synthetic text", Endpoint: "iguana/kb-whisper"}))
|
|
|
|
_ = s.FailUpload(ctx, userA, id, domain.UploadErrInterrupted)
|
|
|
|
got, err := s.GetUpload(ctx, userA, id)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, domain.UploadDone, got.Status)
|
|
assert.Equal(t, "synthetic text", got.Content)
|
|
assert.Empty(t, got.ErrorKind)
|
|
}
|
|
|
|
func TestFailUpload_StillFailsAQueuedOrTranscribingUpload(t *testing.T) {
|
|
s := newStore(t)
|
|
ctx := context.Background()
|
|
queued := startedUpload(t, s)
|
|
running, err := s.CreateUpload(ctx, userA, "r", domain.LangSwedish, false)
|
|
require.NoError(t, err)
|
|
require.NoError(t, s.StartTranscribing(ctx, userA, running))
|
|
|
|
for _, id := range []string{queued, running} {
|
|
require.NoError(t, s.FailUpload(ctx, userA, id, domain.UploadErrBusy))
|
|
got, err := s.GetUpload(ctx, userA, id)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, domain.UploadFailed, got.Status)
|
|
}
|
|
}
|