Files
webrtc/mediaengine_test.go
Woodrow Douglass 3aee69ea60 Add some tests for MediaEngine
Also, centralize the error object returned
from media engine codec searches

Relates to #333
2019-01-23 16:21:13 +01:00

36 lines
686 B
Go

package webrtc
import (
"testing"
"github.com/pions/sdp"
"github.com/stretchr/testify/assert"
)
func TestCodecRegistration(t *testing.T) {
api := NewAPI()
const invalidPT = 255
api.RegisterDefaultCodecs()
testCases := []struct {
c uint8
e error
}{
{DefaultPayloadTypeG722, nil},
{DefaultPayloadTypeOpus, nil},
{DefaultPayloadTypeVP8, nil},
{DefaultPayloadTypeVP9, nil},
{DefaultPayloadTypeH264, nil},
{invalidPT, ErrCodecNotFound},
}
for _, f := range testCases {
_, err := api.mediaEngine.getCodec(f.c)
assert.Equal(t, f.e, err)
}
_, err := api.mediaEngine.getCodecSDP(sdp.Codec{PayloadType: invalidPT})
assert.Equal(t, err, ErrCodecNotFound)
}