forked from audi70r/gochecknat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gochecknat_test.go
46 lines (43 loc) · 1.04 KB
/
gochecknat_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
package gochecknat
import (
"fmt"
"testing"
)
func TestGetNATInfo(t *testing.T) {
tests := []struct {
name string
wantInfo NATInfo
wantErr bool
}{
{
name: "test",
wantInfo: NATInfo{
IP: "",
Port: 0,
Candidates: nil,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotInfo, err := GetNATInfo()
if (err != nil) != tt.wantErr {
t.Errorf("GetNATInfo() error = %v, wantErr %v", err, tt.wantErr)
return
}
if len(gotInfo.Candidates) == len(tt.wantInfo.Candidates) {
t.Errorf("GetNATInfo() gotInfo = %v, want %v", gotInfo, tt.wantInfo)
}
if gotInfo.IP == tt.wantInfo.IP {
t.Errorf("GetNATInfo() gotInfo = %v, want %v", gotInfo, tt.wantInfo)
}
if gotInfo.Port == tt.wantInfo.Port {
t.Errorf("GetNATInfo() gotInfo = %v, want %v", gotInfo, tt.wantInfo)
}
fmt.Printf("\nPUBLIC IP: %v\n", gotInfo.IP)
fmt.Printf("ASSIGNED PORT: %v\n", gotInfo.Port)
fmt.Printf("SYMMERTIC NAT: %v\n\n", gotInfo.Symmetric)
})
}
}