test(uploads): Accept records whether the file had a video track (red)
Red: Store.CreateUpload does not take hadVideo yet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,14 @@ import (
|
|||||||
|
|
||||||
type fakeStore struct {
|
type fakeStore struct {
|
||||||
created []string // titles
|
created []string // titles
|
||||||
|
hadVideo []bool
|
||||||
failed map[string]domain.UploadErrorKind
|
failed map[string]domain.UploadErrorKind
|
||||||
nextID string
|
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.created = append(f.created, title)
|
||||||
|
f.hadVideo = append(f.hadVideo, hadVideo)
|
||||||
return f.nextID, nil
|
return f.nextID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +142,7 @@ func TestAccept_ProbeVerdictRejectsWithoutRowAndRemovesTheFile(t *testing.T) {
|
|||||||
probe uploads.Probe
|
probe uploads.Probe
|
||||||
reason uploads.Reason
|
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},
|
{"too long", uploads.Probe{Duration: 2 * time.Hour, HasAudio: true}, uploads.ReasonTooLong},
|
||||||
{"no audio", uploads.Probe{Duration: time.Minute}, uploads.ReasonNoAudio},
|
{"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")
|
"a row that will never run must not sit queued: that is the stuck spinner ADR-025 forbids")
|
||||||
assert.Empty(t, r.tmpFiles(t))
|
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")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user