4cddfcf2f3
Backend Tests / Tests (other) (push) Failing after 1s
Backend Tests / Static Checks (push) Failing after 2s
Backend Tests / Tests (internal) (push) Failing after 2s
Backend Tests / Tests (server) (push) Failing after 1s
Backend Tests / Tests (store) (push) Failing after 1s
Build Canary Image / build-frontend (push) Failing after 1s
Frontend Tests / Lint (push) Failing after 1s
Build Canary Image / build-push (linux/amd64) (push) Has been skipped
Build Canary Image / build-push (linux/arm64) (push) Has been skipped
Build Canary Image / merge (push) Has been skipped
Frontend Tests / Build (push) Failing after 1s
Release Please / release-please (push) Failing after 0s
Proto Linter / Lint Protos (push) Failing after 2s
49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package audio
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIsWebMContentType(t *testing.T) {
|
|
cases := []struct {
|
|
in string
|
|
want bool
|
|
}{
|
|
{"audio/webm", true},
|
|
{"audio/webm;codecs=opus", true},
|
|
{"audio/webm; codecs=opus", true},
|
|
{"AUDIO/WEBM", true},
|
|
{" audio/webm ", true},
|
|
{"audio/wav", false},
|
|
{"audio/mp4", false},
|
|
{"video/webm", false},
|
|
{"", false},
|
|
{"webm", false},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.in, func(t *testing.T) {
|
|
require.Equal(t, tc.want, IsWebMContentType(tc.in))
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestWebMOpusToWAV_RejectsInvalidInput(t *testing.T) {
|
|
t.Run("empty", func(t *testing.T) {
|
|
_, err := WebMOpusToWAV(nil)
|
|
require.Error(t, err)
|
|
})
|
|
|
|
t.Run("not webm", func(t *testing.T) {
|
|
_, err := WebMOpusToWAV([]byte("hello world this is not webm"))
|
|
require.Error(t, err)
|
|
})
|
|
|
|
t.Run("truncated webm header bytes", func(t *testing.T) {
|
|
// Valid EBML magic but no Segment.
|
|
_, err := WebMOpusToWAV([]byte{0x1A, 0x45, 0xDF, 0xA3})
|
|
require.Error(t, err)
|
|
})
|
|
}
|