Skipped unless TAPIR_LIVE_FFPROBE is set. Synthetic/crafted files only. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
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)
|
|
}
|