improve coverage

This commit is contained in:
aler9
2022-02-01 19:43:59 +01:00
parent 0c9bd7a575
commit 88e1244e9f
2 changed files with 71 additions and 0 deletions

View File

@@ -82,3 +82,73 @@ func TestTrackGenericNewFromMediaDescription(t *testing.T) {
})
}
}
func TestTrackGenericNewFromMediaDescriptionErrors(t *testing.T) {
for _, ca := range []struct {
name string
md *psdp.MediaDescription
err string
}{
{
"no formats",
&psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "audio",
Protos: []string{"RTP", "AVP"},
Formats: []string{},
},
},
"unable to get clock rate: no formats provided",
},
{
"no rtpmap",
&psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"90"},
},
},
"unable to get clock rate: attribute 'rtpmap' not found",
},
{
"invalid rtpmap 1",
&psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "96",
},
},
},
"unable to get clock rate: invalid rtpmap (96)",
},
{
"invalid rtpmap 2",
&psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "96 mpeg4-generic",
},
},
},
"unable to get clock rate: invalid rtpmap (96 mpeg4-generic)",
},
} {
t.Run(ca.name, func(t *testing.T) {
_, err := newTrackGenericFromMediaDescription(ca.md)
require.EqualError(t, err, ca.err)
})
}
}