github.com/nxtrace/NTrace-core@v1.3.1-0.20240513132635-39169291e8c9/reporter/reporter_test.go (about) 1 package reporter 2 3 import ( 4 "net" 5 "testing" 6 "time" 7 8 "github.com/nxtrace/NTrace-core/ipgeo" 9 "github.com/nxtrace/NTrace-core/trace" 10 ) 11 12 var testResult = &trace.Result{ 13 Hops: [][]trace.Hop{ 14 { 15 { 16 Success: true, 17 Address: &net.IPAddr{IP: net.ParseIP("192.168.3.1")}, 18 Hostname: "test", 19 TTL: 0, 20 RTT: 10 * time.Millisecond, 21 Error: nil, 22 Geo: &ipgeo.IPGeoData{ 23 Asnumber: "4808", 24 Country: "中国", 25 Prov: "北京市", 26 City: "北京市", 27 District: "北京市", 28 Owner: "", 29 Isp: "中国联通", 30 }, 31 }, 32 }, 33 { 34 { 35 Success: true, 36 Address: &net.IPAddr{IP: net.ParseIP("114.249.16.1")}, 37 Hostname: "test", 38 TTL: 0, 39 RTT: 10 * time.Millisecond, 40 Error: nil, 41 Geo: &ipgeo.IPGeoData{ 42 Asnumber: "4808", 43 Country: "中国", 44 Prov: "北京市", 45 City: "北京市", 46 District: "北京市", 47 Owner: "", 48 Isp: "中国联通", 49 }, 50 }, 51 }, 52 { 53 { 54 Success: true, 55 Address: &net.IPAddr{IP: net.ParseIP("219.158.5.150")}, 56 Hostname: "test", 57 TTL: 0, 58 RTT: 10 * time.Millisecond, 59 Error: nil, 60 Geo: &ipgeo.IPGeoData{ 61 Asnumber: "4837", 62 Country: "中国", 63 Prov: "", 64 City: "", 65 District: "", 66 Owner: "", 67 Isp: "中国联通", 68 }, 69 }, 70 }, 71 { 72 { 73 Success: true, 74 Address: &net.IPAddr{IP: net.ParseIP("62.115.125.160")}, 75 Hostname: "test", 76 TTL: 0, 77 RTT: 10 * time.Millisecond, 78 Error: nil, 79 Geo: &ipgeo.IPGeoData{ 80 Asnumber: "1299", 81 Country: "Sweden", 82 Prov: "Stockholm County", 83 City: "Stockholm", 84 District: "", 85 Owner: "", 86 Isp: "Telia Company AB", 87 }, 88 }, 89 }, 90 { 91 { 92 Success: true, 93 Address: &net.IPAddr{IP: net.ParseIP("213.226.68.73")}, 94 Hostname: "test", 95 TTL: 0, 96 RTT: 10 * time.Millisecond, 97 Error: nil, 98 Geo: &ipgeo.IPGeoData{ 99 Asnumber: "56630", 100 Country: "Germany", 101 Prov: "Hesse, Frankfurt", 102 City: "", 103 District: "", 104 Owner: "", 105 Isp: "Melbikomas UAB", 106 }, 107 }, 108 }, 109 }, 110 } 111 112 func TestPrint(t *testing.T) { 113 r := New(testResult, "213.226.68.73") 114 r.Print() 115 }