notifiers: Stop using url.Parse in validating address format. (#4011)

url.Parse() wrongly parses an address of format "address:port"
which is fixed in go1.8.  This inculcates a breaking change
on our end. We should fix this wrong usage everywhere so that
migrating to go1.8 eventually becomes smoother.
This commit is contained in:
Harshavardhana
2017-03-31 04:47:40 -07:00
committed by GitHub
parent 096427f973
commit f1015a5096
7 changed files with 22 additions and 14 deletions
+3 -5
View File
@@ -389,16 +389,14 @@ func TestLocalAddress(t *testing.T) {
}
// TestCheckURL tests valid address
// TestCheckURL tests valid url.
func TestCheckURL(t *testing.T) {
testCases := []struct {
addr string
urlStr string
shouldPass bool
}{
{"", false},
{":", false},
{"localhost", true},
{"127.0.0.1", true},
{"http://localhost/", true},
{"http://127.0.0.1/", true},
{"proto://myhostname/path", true},
@@ -406,7 +404,7 @@ func TestCheckURL(t *testing.T) {
// Validates fetching local address.
for i, testCase := range testCases {
_, err := checkURL(testCase.addr)
_, err := checkURL(testCase.urlStr)
if testCase.shouldPass && err != nil {
t.Errorf("Test %d: expected to pass but got an error: %v\n", i+1, err)
}