(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestValidateHostname(t *testing.T) { |
| 22 | var inputHostname string |
| 23 | hostname, err := ValidateHostname(inputHostname) |
| 24 | assert.Equal(t, err, nil) |
| 25 | assert.Empty(t, hostname) |
| 26 | |
| 27 | inputHostname = "hello.example.com" |
| 28 | hostname, err = ValidateHostname(inputHostname) |
| 29 | assert.Nil(t, err) |
| 30 | assert.Equal(t, "hello.example.com", hostname) |
| 31 | |
| 32 | inputHostname = "http://hello.example.com" |
| 33 | hostname, err = ValidateHostname(inputHostname) |
| 34 | assert.Nil(t, err) |
| 35 | assert.Equal(t, "hello.example.com", hostname) |
| 36 | |
| 37 | inputHostname = "bücher.example.com" |
| 38 | hostname, err = ValidateHostname(inputHostname) |
| 39 | assert.Nil(t, err) |
| 40 | assert.Equal(t, "xn--bcher-kva.example.com", hostname) |
| 41 | |
| 42 | inputHostname = "http://bücher.example.com" |
| 43 | hostname, err = ValidateHostname(inputHostname) |
| 44 | assert.Nil(t, err) |
| 45 | assert.Equal(t, "xn--bcher-kva.example.com", hostname) |
| 46 | |
| 47 | inputHostname = "http%3A%2F%2Fhello.example.com" |
| 48 | hostname, err = ValidateHostname(inputHostname) |
| 49 | assert.Nil(t, err) |
| 50 | assert.Equal(t, "hello.example.com", hostname) |
| 51 | |
| 52 | } |
| 53 | |
| 54 | func TestValidateUrl(t *testing.T) { |
| 55 | type testCase struct { |
nothing calls this directly
no test coverage detected