Skip to content

Commit

Permalink
Fix unit tests (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
bli-r7 authored Oct 25, 2021
1 parent 16249a5 commit ebe75b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions proxy/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ var dataProviderParseEnvHTTPSProxy = []struct {
{"HTTPS://test:8080", newTestProxy("https", "test", 8080, nil, "Environment[Key]"), nil},
{"test:8999", newTestProxy("", "test", 8999, nil, "Environment[Key]"), nil},
// Invalid
{"://test:8080", nil, errors.New("parse ://test:8080: missing protocol scheme")},
{"://test:8080", nil, errors.New("parse \"://test:8080\": missing protocol scheme")},
// TODO These error cases are introduced after Go 1.7
//{"https", "https://[test:8080", nil, errors.New("parse https://[test:8080: missing ']' in host")},
//{"https", "https://username:1412¶45124@test:8080", nil, errors.New("parse https://username:1412¶45124@test:8080: net/url: invalid userinfo")},
Expand Down Expand Up @@ -300,7 +300,7 @@ var dataProviderParseEnvURL = []struct {
{"", nil, new(notFoundError)},
{" ", nil, new(notFoundError)},
// Invalid
{"://test:8080", nil, errors.New("parse ://test:8080: missing protocol scheme")},
{"://test:8080", nil, errors.New("parse \"://test:8080\": missing protocol scheme")},
// TODO These error cases are introduced after Go 1.7
//{"https://[test:8080", nil, errors.New("parse https://[test:8080: missing ']' in host")},
//{"https://username:1412¶45124@test:8080", nil, errors.New("parse https://username:1412¶45124@test:8080: net/url: invalid userinfo")},
Expand Down
4 changes: 2 additions & 2 deletions proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ var dataNewProxy = []struct {
// Invalid port
{
&url.URL{Scheme: "https", Host: "testProxy:testPort"},
nil, errors.New("SplitHostPort testProxy:testPort: strconv.ParseUint: parsing \"testPort\": invalid syntax"),
nil, errors.New("SplitHostPort \"testProxy:testPort\": strconv.ParseUint: parsing \"testPort\": invalid syntax"),
},
// Negative port
{
&url.URL{Scheme: "https", Host: "testProxy:-1"},
nil, errors.New("SplitHostPort testProxy:-1: strconv.ParseUint: parsing \"-1\": invalid syntax"),
nil, errors.New("SplitHostPort \"testProxy:-1\": strconv.ParseUint: parsing \"-1\": invalid syntax"),
},
// Empty host
{
Expand Down
10 changes: 5 additions & 5 deletions proxy/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var dataParseURL = []struct {
{"", "", &url.URL{}, nil},
{"", "https", &url.URL{Scheme: "https"}, nil},
// Invalid cases
{"://test:8080", "", nil, errors.New("parse ://test:8080: missing protocol scheme")},
{"://test:8080", "", nil, errors.New("parse \"://test:8080\": missing protocol scheme")},
// TODO These error cases are introduced after Go 1.7
//{"https://[test:8080", "", nil, errors.New("parse https://[test:8080: missing ']' in host")},
//{"https://username:1412¶45124@test:8080", "", nil, errors.New("parse https://username:1412¶45124@test:8080: net/url: invalid userinfo")},
Expand Down Expand Up @@ -166,13 +166,13 @@ var dataSplitHostPort = []struct {
// port Max
{&url.URL{Host: "test:65535"}, "test", 65535, nil},
// Invalid - port NaN
{&url.URL{Host: "test1:test2"}, "", 0, errors.New("SplitHostPort test1:test2: strconv.ParseUint: parsing \"test2\": invalid syntax")},
{&url.URL{Host: "test1:test2"}, "", 0, errors.New("SplitHostPort \"test1:test2\": strconv.ParseUint: parsing \"test2\": invalid syntax")},
// Invalid - port Exceeded
{&url.URL{Host: "test1:65536"}, "", 0, errors.New("SplitHostPort test1:65536: strconv.ParseUint: parsing \"65536\": value out of range")},
{&url.URL{Host: "test1:65536"}, "", 0, errors.New("SplitHostPort \"test1:65536\": strconv.ParseUint: parsing \"65536\": value out of range")},
// Invalid - port signed
{&url.URL{Host: "test1:-1"}, "", 0, errors.New("SplitHostPort test1:-1: strconv.ParseUint: parsing \"-1\": invalid syntax")},
{&url.URL{Host: "test1:-1"}, "", 0, errors.New("SplitHostPort \"test1:-1\": strconv.ParseUint: parsing \"-1\": invalid syntax")},
// Invalid - nil URL
{nil, "", 0, errors.New("SplitHostPort nil: nil URL")},
{nil, "", 0, errors.New("SplitHostPort \"nil\": nil URL")},
}

func TestSplitHostPort(t *testing.T) {
Expand Down

0 comments on commit ebe75b1

Please sign in to comment.