diff --git a/internal/uploads/intake_test.go b/internal/uploads/intake_test.go index 0fcafc1..fb2e39c 100644 --- a/internal/uploads/intake_test.go +++ b/internal/uploads/intake_test.go @@ -20,13 +20,15 @@ import ( ) type fakeStore struct { - created []string // titles - failed map[string]domain.UploadErrorKind - nextID string + created []string // titles + hadVideo []bool + failed map[string]domain.UploadErrorKind + nextID string } -func (f *fakeStore) CreateUpload(_ context.Context, _, title string) (string, error) { +func (f *fakeStore) CreateUpload(_ context.Context, _, title string, hadVideo bool) (string, error) { f.created = append(f.created, title) + f.hadVideo = append(f.hadVideo, hadVideo) return f.nextID, nil } @@ -140,7 +142,7 @@ func TestAccept_ProbeVerdictRejectsWithoutRowAndRemovesTheFile(t *testing.T) { probe uploads.Probe reason uploads.Reason }{ - {"video", uploads.Probe{Duration: time.Minute, HasAudio: true, HasVideo: true}, uploads.ReasonVideo}, + {"video with no audio", uploads.Probe{Duration: time.Minute, HasVideo: true}, uploads.ReasonNoAudio}, {"too long", uploads.Probe{Duration: 2 * time.Hour, HasAudio: true}, uploads.ReasonTooLong}, {"no audio", uploads.Probe{Duration: time.Minute}, uploads.ReasonNoAudio}, } @@ -210,3 +212,28 @@ func TestAccept_SubmitFailureFailsTheRowHonestlyAndRemovesTheFile(t *testing.T) "a row that will never run must not sit queued: that is the stuck spinner ADR-025 forbids") assert.Empty(t, r.tmpFiles(t)) } + +func TestAccept_AFileWithAVideoTrackIsAcceptedAndRecordsThatItHadOne(t *testing.T) { + tests := []struct { + name string + probe uploads.Probe + wantVideo bool + }{ + {"audio only", uploads.Probe{Duration: 10 * time.Minute, HasAudio: true}, false}, + {"audio with a video track (a Teams meeting with the camera off)", uploads.Probe{Duration: 10 * time.Minute, HasAudio: true, HasVideo: true}, true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + r := newRig(t) + r.pr.probe = tt.probe + + id, err := r.in.Accept(context.Background(), "user-1", "t", strings.NewReader("data")) + + require.NoError(t, err) + assert.Equal(t, "up-1", id) + assert.Equal(t, []bool{tt.wantVideo}, r.st.hadVideo, + "the row must say whether a video track was present, so the page can say it was ignored") + assert.Len(t, r.sub.jobs, 1, "it is queued like any other recording") + }) + } +}