forked from cosmos/rosetta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
69 lines (66 loc) · 1.57 KB
/
config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package rosetta
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestConfig_validateUrl(t *testing.T) {
tests := []struct {
name string
tendermintRPC string
expected string
}{
{
name: "complete url",
tendermintRPC: "https://myhost.com:443",
expected: "https://myhost.com:443",
},
{
name: "no schema no port",
tendermintRPC: "myhost.com",
expected: "http://myhost.com:80",
},
{
name: "http schema with no port",
tendermintRPC: "http://myHost.com",
expected: "http://myhost.com:80",
},
{
name: "https schema with no port",
tendermintRPC: "https://myHost.com",
expected: "https://myhost.com:443",
},
{
name: "no schema with port",
tendermintRPC: "myHost.com:2344",
expected: "http://myhost.com:2344",
},
{
name: "no schema with port 443",
tendermintRPC: "myHost.com:443",
expected: "https://myhost.com:443",
},
{
name: "tcp schema",
tendermintRPC: "tcp://localhost:26657",
expected: "tcp://localhost:26657",
},
{
name: "localhost",
tendermintRPC: "localhost",
expected: "http://localhost:80",
},
{
name: "not normalized url",
tendermintRPC: "hTTp://tHISmyWebsite.COM",
expected: "http://thismywebsite.com:80",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Config{}
got, err := c.validateURL(tt.tendermintRPC)
require.NoError(t, err)
require.Equal(t, tt.expected, got)
})
}
}