...
1 package internal
2
3 import (
4 "net/url"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 "github.com/stretchr/testify/require"
9 )
10
11 func TestUrlnorm(t *testing.T) {
12 testCases := []struct {
13 url string
14 expected string
15 }{
16 {
17 url: "HTTPs://xYz.cOm:443/folder//file",
18 expected: "https://xyz.com/folder/file",
19 },
20 {
21 url: "HTTP://xYz.cOm:80/folder//file",
22 expected: "http://xyz.com/folder/file",
23 },
24 {
25 url: "postGRES://xYz.cOm:5432/folder//file",
26 expected: "postgres://xyz.com:5432/folder/file",
27 },
28 }
29
30 for _, toPin := range testCases {
31 testCase := toPin
32
33 u, err := url.Parse(testCase.url)
34 require.NoError(t, err)
35
36 NormalizeURL(u)
37 assert.Equal(t, testCase.expected, u.String())
38 }
39 }
40
View as plain text