diff --git a/internal/adapters/audio/hostile_live_test.go b/internal/adapters/audio/hostile_live_test.go new file mode 100644 index 0000000..35a0958 --- /dev/null +++ b/internal/adapters/audio/hostile_live_test.go @@ -0,0 +1,32 @@ +package audio_test + +import ( + "context" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "git.d-ma.be/mathias/tapir/internal/adapters/audio" + "git.d-ma.be/mathias/tapir/internal/uploads" +) + +// TestFFprobeLive_HostilePlaylistsAreRefusedAndRealAudioIsNot runs the REAL ffprobe +// (opt-in: TAPIR_LIVE_FFPROBE) on crafted concat/HLS files and on a real m4a. +func TestFFprobeLive_HostilePlaylistsAreRefusedAndRealAudioIsNot(t *testing.T) { + bin := os.Getenv("TAPIR_LIVE_FFPROBE") + if bin == "" { + t.Skip("set TAPIR_LIVE_FFPROBE (and TAPIR_LIVE_HOSTILE_DIR, TAPIR_LIVE_M4A) to run against the real ffprobe") + } + p := &audio.FFprobe{Bin: bin} + for _, name := range []string{"up-concat", "up-hls"} { + _, err := p.Probe(context.Background(), os.Getenv("TAPIR_LIVE_HOSTILE_DIR")+"/"+name) + assert.ErrorIs(t, err, uploads.ErrUnreadable, name) + } + got, err := p.Probe(context.Background(), os.Getenv("TAPIR_LIVE_M4A")) + require.NoError(t, err) + assert.True(t, got.HasAudio) + assert.False(t, got.HasVideo) + assert.InDelta(t, 82.5, got.Duration.Seconds(), 1) +}