Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardsn committed Oct 25, 2023
1 parent 13f6cb3 commit 5fabf8b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ func Test_ParsePublicURL(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "https://non.reserved", u.String())
})
t.Run("error - strict", func(t *testing.T) {
t.Run("error - strict - scheme must be https", func(t *testing.T) {
u, err := ParsePublicURL("http://localhost", true)
assert.Nil(t, u)
assert.EqualError(t, err, "scheme must be https")
})
t.Run("error - strict - reserved address", func(t *testing.T) {
u, err := ParsePublicURL("https://localhost", true)
assert.Nil(t, u)
assert.EqualError(t, err, "hostname is RFC2606 reserved")
})
t.Run("error - strict - IP address", func(t *testing.T) {
u, err := ParsePublicURL("https://127.0.0.1", true)
assert.Nil(t, u)
assert.EqualError(t, err, "hostname is IP")
})
t.Run("ok - non-strict", func(t *testing.T) {
u, err := ParsePublicURL("http://localhost", false)
require.NoError(t, err)
Expand Down

0 comments on commit 5fabf8b

Please sign in to comment.