Skip to content

Commit

Permalink
Test format probing
Browse files Browse the repository at this point in the history
  • Loading branch information
IljaN committed Sep 29, 2024
1 parent 5226d1b commit 762cb3a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/stretchr/testify/assert"
"os"
"strings"
"testing"
)
Expand All @@ -17,3 +18,27 @@ func TestToDownloadPath(t *testing.T) {
downloadPath = toDownloadPath(videoUrl, downloadDir)
assert.True(t, strings.HasPrefix(downloadPath, "/tmp/foo/DL-"))
}

func TestProbeFileFormat(t *testing.T) {
testCases := []struct {
filePath string
isAudio bool
}{
{"test/testdata/audio_iso6.mp4", true},
{"test/testdata/audio_mp42.mp4", true},
{"test/testdata/vid.mp4", false},
}

for _, tc := range testCases {
t.Run(tc.filePath, func(t *testing.T) {
data, err := os.ReadFile(tc.filePath)
if err != nil {
t.Fatal(err)
}

isAudio, err := probeFileFormat(data)
assert.Nil(t, err)
assert.Equal(t, tc.isAudio, isAudio)
})
}
}
Binary file added test/testdata/audio_iso6.mp4
Binary file not shown.
Binary file added test/testdata/audio_mp42.mp4
Binary file not shown.
Binary file added test/testdata/vid.mp4
Binary file not shown.

0 comments on commit 762cb3a

Please sign in to comment.