diff --git a/cmd/tapir/uploads_converter_test.go b/cmd/tapir/uploads_converter_test.go new file mode 100644 index 0000000..a8bde82 --- /dev/null +++ b/cmd/tapir/uploads_converter_test.go @@ -0,0 +1,26 @@ +package main + +import ( + "testing" + "time" + + "git.d-ma.be/mathias/tapir/internal/config" +) + +// The converter is told the configured maximum, so a file whose header lies about its +// length cannot become hours of WAV (adversarial review F2). + +func TestNewConverter_IsCappedAtTheConfiguredMaximumDuration(t *testing.T) { + var cfg config.Config + cfg.FFmpegBin = "/usr/local/bin/ffmpeg" + cfg.UploadMaxDuration = 90 * time.Minute + + c := newConverter(cfg) + + if c.Bin != "/usr/local/bin/ffmpeg" { + t.Errorf("Bin = %q", c.Bin) + } + if c.MaxSeconds != 5400 { + t.Errorf("MaxSeconds = %v, want 5400", c.MaxSeconds) + } +}