Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test format probing #8

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading