-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_test.go
69 lines (59 loc) · 1.75 KB
/
client_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 rtpengine
import (
"fmt"
"net"
"testing"
"github.com/stretchr/testify/require"
)
func TestClientRequestNewClientWithClientPort(t *testing.T) {
rtp, err := NewClient(
&Engine{
ip: net.ParseIP("10.0.0.0"),
},
WithClientPort(2222),
WithClientProto("udp"))
require.Nil(t, err)
require.NotNil(t, &rtp.port)
fmt.Println("Func:", t.Name(), "Valor:", rtp.port)
}
func TestClientRequestNewClientWithClientHostname(t *testing.T) {
rtp, err := NewClient(
&Engine{
ip: net.ParseIP("10.0.0.0"),
},
WithClientHostname("L5NB-JGZXMF3"),
//WithClientHostname("DESKTOP-QJ365M6"),
WithClientProto("udp"))
require.Nil(t, err)
require.NotNil(t, rtp.ip)
fmt.Println("Func:", t.Name(), "Valor:", rtp.ip, "PASS")
}
func TestClientRequestNewClienWithClientDns(t *testing.T) {
rtp, err := NewClient(
&Engine{
ip: net.ParseIP("10.0.0.0"),
},
WithClientDns("webrtcsrvgcp.callbox.com.br"),
WithClientProto("udp"))
require.Nil(t, err)
require.NotNil(t, rtp.url)
fmt.Println("Func:", t.Name(), "Valor:", rtp.url, "PASS")
}
func TestClientRequestClientOption(t *testing.T) {
t.Run("TestClientDNS", func(t *testing.T) {
c := &Engine{}
client, err := NewClient(c, WithClientPort(2222), WithClientProto("udp"), WithClientDns("webrtcsrvgcp.callbox.com.br"))
require.Nil(t, err)
require.NotNil(t, client.Engine.con)
fmt.Println("Func:", t.Name(), "Valor:", client.con.RemoteAddr().String(), "PASS")
c.con.Close()
})
t.Run("TestClientIP", func(t *testing.T) {
b := &Engine{}
clt, err := NewClient(b, WithClientPort(2222), WithClientProto("udp"), WithClientIP("35.198.31.42"))
require.Nil(t, err)
require.NotNil(t, clt.Engine.con)
fmt.Println("Func:", t.Name(), "Valor:", clt.con.RemoteAddr().String(), "PASS")
b.con.Close()
})
}