- Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathembedded_ui_test.go
59 lines (53 loc) · 960 Bytes
/
embedded_ui_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
package embeddedui
import (
"testing"
"github.com/stretchr/testify/require"
)
funcTestUIManagerOriginURL(t*testing.T) {
testCases:= []struct {
hoststring
portint
resultstring
}{
{
host: "example.com",
port: 2345,
result: "http://example.com:2345",
},
{
host: "example.com",
result: "http://example.com:0",
},
{
host: "container_host",
port: 2345,
result: "http://container_host:2345",
},
{
host: "172.168.1.1",
port: 2345,
result: "http://172.168.1.1:2345",
},
{
host: "0.0.0.0",
port: 2345,
result: "http://127.0.0.1:2345",
},
{
host: "",
port: 2345,
result: "http://127.0.0.1:2345",
},
}
for_, tc:=rangetestCases {
uiManager:=UIManager{
cfg: Config{
Enabled: true,
Host: tc.host,
Port: tc.port,
},
}
require.True(t, uiManager.IsEnabled())
require.Equal(t, tc.result, uiManager.OriginURL())
}
}