mirror of
https://github.com/pion/ice.git
synced 2025-10-05 15:37:07 +08:00
Make error test portable
Fix URL error test portable on multiple Go versions.
This commit is contained in:
13
url_test.go
13
url_test.go
@@ -2,6 +2,9 @@ package ice
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -49,8 +52,8 @@ func TestParseURL(t *testing.T) {
|
||||
expectedErr error
|
||||
}{
|
||||
{"", ErrSchemeType},
|
||||
{":::", errors.New("parse :::: missing protocol scheme")},
|
||||
{"stun:[::1]:123:", errors.New("address [::1]:123:: too many colons in address")},
|
||||
{":::", errors.New("missing protocol scheme")},
|
||||
{"stun:[::1]:123:", errors.New("too many colons in address")},
|
||||
{"stun:[::1]:123a", ErrPort},
|
||||
{"google.de", ErrSchemeType},
|
||||
{"stun:", ErrHost},
|
||||
@@ -65,6 +68,12 @@ func TestParseURL(t *testing.T) {
|
||||
|
||||
for i, testCase := range testCases {
|
||||
_, err := ParseURL(testCase.rawURL)
|
||||
switch e := err.(type) {
|
||||
case *url.Error:
|
||||
err = e.Err
|
||||
case *net.AddrError:
|
||||
err = fmt.Errorf("%v", e.Err)
|
||||
}
|
||||
assert.EqualError(t, err, testCase.expectedErr.Error(), "testCase: %d %v", i, testCase)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user