Skip to content

Commit f0c4982

Browse files
committed
Revert invalid port message, fix test
1 parent 1ef6a1f commit f0c4982

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

unmarshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ func unmarshalMediaDescription(lex *lexer) (stateFn, error) { //nolint:cyclop
811811
parts := strings.Split(field, "/")
812812
newMediaDesc.MediaName.Port.Value, err = parsePort(parts[0])
813813
if err != nil {
814-
return nil, err
814+
return nil, fmt.Errorf("%w `%v`", errSDPInvalidPortValue, parts[0])
815815
}
816816

817817
if len(parts) > 1 {

unmarshal_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package sdp
55

66
import (
7-
"fmt"
87
"testing"
98

109
"github.com/stretchr/testify/assert"
@@ -403,11 +402,11 @@ func TestUnmarshalPortRange(t *testing.T) {
403402
}{
404403
{
405404
In: SessionAttributesSDP + "m=video -1 RTP/AVP 99\r\n",
406-
ExpectError: fmt.Errorf("%w -- out of range `%v`", errSDPInvalidPortValue, "-1"),
405+
ExpectError: errSDPInvalidPortValue,
407406
},
408407
{
409408
In: SessionAttributesSDP + "m=video 65536 RTP/AVP 99\r\n",
410-
ExpectError: fmt.Errorf("%w -- out of range `%v`", errSDPInvalidPortValue, "65536"),
409+
ExpectError: errSDPInvalidPortValue,
411410
},
412411
{
413412
In: SessionAttributesSDP + "m=video 0 RTP/AVP 99\r\n",
@@ -419,15 +418,15 @@ func TestUnmarshalPortRange(t *testing.T) {
419418
},
420419
{
421420
In: SessionAttributesSDP + "m=video --- RTP/AVP 99\r\n",
422-
ExpectError: fmt.Errorf("%w `%v`", errSDPInvalidPortValue, "---"),
421+
ExpectError: errSDPInvalidPortValue,
423422
},
424423
} {
425424
var sd SessionDescription
426425
err := sd.UnmarshalString(test.In)
427-
if err != nil && test.ExpectError != nil {
428-
assert.Equal(t, test.ExpectError.Error(), err.Error())
426+
if test.ExpectError != nil {
427+
assert.ErrorIs(t, err, test.ExpectError)
429428
} else {
430-
assert.Equal(t, err, test.ExpectError)
429+
assert.NoError(t, err)
431430
}
432431
}
433432
}

0 commit comments

Comments
 (0)