@@ -110,7 +110,7 @@ func TestLatencyOutput(t *testing.T) {
110110 t .Fatalf ("expected path %v; got %v" , exp , got )
111111 }
112112
113- const body = `{"id": "2e9fd0e3a444adddb9b8168e6e0f856c","items": [{"id": "186b4c4c77985f75e7cefc48289e79ff","result": {"ip": "74.125.200.113","output": "35.223","node": {"id": 58,"latitude": 22.280042521009999,"longitude": 114.1915512085,"country": {"id": 195,"name": "Hong Kong","continent": {"id": 2,"name": "Asia","iso": "AS"},"iso": "HK","iso_numeric": "344"},"city": "Hong Kong","sub_region": "Eastern Asia"}}}, {"id": "34ae843cf4d341b252a14e3d6b39281f","result": {"output": -1,"message": "100% packet loss","node": {"id": 208,"latitude": 30.255360295637001,"longitude": 120.15712738037,"country": {"id": 62,"name": "China","continent": {"id": 2,"name": "Asia","iso": "AS"},"iso": "CN","iso_numeric": "156"},"city": "Hangzhou","sub_region": "Eastern Asia"}}}],"requested": "google.com","finished": "true"}`
113+ const body = `{"id": "2e9fd0e3a444adddb9b8168e6e0f856c","items": [{"id": "186b4c4c77985f75e7cefc48289e79ff","result": {"ip": "74.125.200.113","output": "35.223","node": {"id": 58,"as_number": 12345," latitude": 22.280042521009999,"longitude": 114.1915512085,"country": {"id": 195,"name": "Hong Kong","continent": {"id": 2,"name": "Asia","iso": "AS"},"iso": "HK","iso_numeric": "344"},"city": "Hong Kong","sub_region": "Eastern Asia"}}}, {"id": "34ae843cf4d341b252a14e3d6b39281f","result": {"output": -1,"message": "100% packet loss","node": {"id": 208,"as_number": 23456 ,"latitude": 30.255360295637001,"longitude": 120.15712738037,"country": {"id": 62,"name": "China","continent": {"id": 2,"name": "Asia","iso": "AS"},"iso": "CN","iso_numeric": "156"},"city": "Hangzhou","sub_region": "Eastern Asia"}}}],"requested": "google.com","finished": "true"}`
114114 tr2 := & respondingTransport {resp : dummyResp (201 , "GET" , body )}
115115 c , err = newTestClient (tr2 )
116116 if err != nil {
@@ -281,7 +281,7 @@ func TestDNSPerfOutput(t *testing.T) {
281281 finished bool
282282 }{
283283 "Incomplete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}` )}, nil , false },
284- "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "6938330049d86df74bb2d0c76f3479de","items": [{"id": "68d10bfb6a9c7f9c519d17df83bc389e","result": {"dnsServer": "8.8.8.8","output": "35","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "google.com","finished": "true"}` )}, nil , true },
284+ "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "6938330049d86df74bb2d0c76f3479de","items": [{"id": "68d10bfb6a9c7f9c519d17df83bc389e","result": {"dnsServer": "8.8.8.8","output": "35","node": {"id": 5,"as_number": 23456," latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "google.com","finished": "true"}` )}, nil , true },
285285 }
286286 ctx := context .Background ()
287287 for name , tc := range testCases {
@@ -366,7 +366,7 @@ func TestDNSResolveOutput(t *testing.T) {
366366 finished bool
367367 }{
368368 "Incomplete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}` )}, nil , false },
369- "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "66b78cfc643ea238e0fd8ab44f512657","items": [{"id": "ae3e8bcd0fbe77d6322b89371d87d96d","result": {"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "bing.com","finished": "true"}` )}, nil , true },
369+ "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "66b78cfc643ea238e0fd8ab44f512657","items": [{"id": "ae3e8bcd0fbe77d6322b89371d87d96d","result": {"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"as_number": 23456," latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "bing.com","finished": "true"}` )}, nil , true },
370370 }
371371 ctx := context .Background ()
372372 for name , tc := range testCases {
@@ -391,8 +391,8 @@ func TestDNSTestResult_ResolveOutput(t *testing.T) {
391391 data []byte
392392 output []string
393393 }{
394- "String" : {[]byte (`{"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` ), []string {"204.79.197.200" , "13.107.21.200" }},
395- "Array" : {[]byte (`{"dnsServer":"8.8.8.8","output":["104.16.85.20","104.16.87.20","104.16.88.20","104.16.86.20","104.16.89.20"],"node":{"id":127,"latitude":34.021790882354999,"longitude":-118.20224761963,"country":{"id":168,"name":"United States","continent":{"id":4,"name":"North America","iso":"NA"},"iso":"US","iso_numeric":"840","is_eu":false},"city":"Los Angeles","sub_region":"Northern America"},"finished":true,"time":1519397739.7899001}` ), []string {"104.16.85.20" , "104.16.87.20" , "104.16.88.20" , "104.16.86.20" , "104.16.89.20" }},
394+ "String" : {[]byte (`{"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"as_number": 23456," latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` ), []string {"204.79.197.200" , "13.107.21.200" }},
395+ "Array" : {[]byte (`{"dnsServer":"8.8.8.8","output":["104.16.85.20","104.16.87.20","104.16.88.20","104.16.86.20","104.16.89.20"],"node":{"id":127,"as_number": 23456," latitude":34.021790882354999,"longitude":-118.20224761963,"country":{"id":168,"name":"United States","continent":{"id":4,"name":"North America","iso":"NA"},"iso":"US","iso_numeric":"840","is_eu":false},"city":"Los Angeles","sub_region":"Northern America"},"finished":true,"time":1519397739.7899001}` ), []string {"104.16.85.20" , "104.16.87.20" , "104.16.88.20" , "104.16.86.20" , "104.16.89.20" }},
396396 }
397397 eq := func (a , b []string ) bool {
398398 if len (a ) != len (b ) {
@@ -485,7 +485,7 @@ func TestCurlOutput(t *testing.T) {
485485 finished bool
486486 }{
487487 "Incomplete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}` )}, nil , false },
488- "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "9b8253c07b53b2db82b05475f9895f4e","items": [{"id": "99e4a2c3d6c8c7e36681515a2d2978e5","result": {"output": "HTTP/1.1 301 Moved Permanently\nContent-length: 0\nLocation: https://github.com/\n\n","node": {"id": 218,"latitude": 49.09803738740174,"longitude": 12.484245300292855,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Falkenstein","sub_region": "Western Europe"}}}],"requested": "github.com","finished": "true"}` )}, nil , true },
488+ "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "9b8253c07b53b2db82b05475f9895f4e","items": [{"id": "99e4a2c3d6c8c7e36681515a2d2978e5","result": {"output": "HTTP/1.1 301 Moved Permanently\nContent-length: 0\nLocation: https://github.com/\n\n","node": {"id": 218,"as_number": 23456," latitude": 49.09803738740174,"longitude": 12.484245300292855,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Falkenstein","sub_region": "Western Europe"}}}],"requested": "github.com","finished": "true"}` )}, nil , true },
489489 }
490490 ctx := context .Background ()
491491 for name , tc := range testCases {
@@ -511,7 +511,7 @@ func TestPerfOuput(t *testing.T) {
511511 exp string
512512 }{
513513 "Invalid" : {"{}" , "-" },
514- "Valid" : {`{"dnsServer": "8.8.8.8","output": "35","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` , "35" },
514+ "Valid" : {`{"dnsServer": "8.8.8.8","output": "35","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"as_number": 23456," name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` , "35" },
515515 }
516516 for name , tc := range testCases {
517517 t .Run (name , func (t * testing.T ) {
@@ -544,7 +544,7 @@ func TestResolveOuput(t *testing.T) {
544544 exp []string
545545 }{
546546 "Invalid" : {"{}" , []string {"-" }},
547- "Valid" : {`{"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` , []string {"204.79.197.200" , "13.107.21.200" }},
547+ "Valid" : {`{"dnsServer": "8.8.8.8","output": "204.79.197.200\n13.107.21.200","node": {"id": 5,"as_number": 23456," latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}` , []string {"204.79.197.200" , "13.107.21.200" }},
548548 }
549549 for name , tc := range testCases {
550550 t .Run (name , func (t * testing.T ) {
@@ -679,7 +679,7 @@ func TestDoGetRunOutput(t *testing.T) {
679679 finished bool
680680 }{
681681 "Incomplete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id":"d1f2408ff","items":[{"id":"734df82","result":{"id":123,"message":"NO DATA"}}]}` )}, nil , false },
682- "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "65d2bb722be16277e3fa8e8c86d3afb7","items": [{"id": "0981fcaf99f2c1b4a46a22cedb417347","result": {"output": "PING bing.com (204.79.197.200): 56 data bytes\n64 bytes from 204.79.197.200: icmp_seq=0 ttl=119 time=40.348 ms\n64 bytes from 204.79.197.200: icmp_seq=1 ttl=119 time=40.198 ms\n64 bytes from 204.79.197.200: icmp_seq=2 ttl=119 time=40.241 ms\n--- bing.com ping statistics ---\n3 packets transmitted, 3 packets received, 0% packet loss\nround-trip min/avg/max/stddev = 40.198/40.262/40.348/0.063 ms\n","node": {"id": 5,"latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "bing.com","finished": "true"}` )}, nil , true },
682+ "Complete" : {& respondingTransport {resp : dummyResp (200 , "GET" , `{"id": "65d2bb722be16277e3fa8e8c86d3afb7","items": [{"id": "0981fcaf99f2c1b4a46a22cedb417347","result": {"output": "PING bing.com (204.79.197.200): 56 data bytes\n64 bytes from 204.79.197.200: icmp_seq=0 ttl=119 time=40.348 ms\n64 bytes from 204.79.197.200: icmp_seq=1 ttl=119 time=40.198 ms\n64 bytes from 204.79.197.200: icmp_seq=2 ttl=119 time=40.241 ms\n--- bing.com ping statistics ---\n3 packets transmitted, 3 packets received, 0% packet loss\nround-trip min/avg/max/stddev = 40.198/40.262/40.348/0.063 ms\n","node": {"id": 5,"as_number": 23456," latitude": 50.110781326572834,"longitude": 8.68984222412098,"country": {"id": 116,"name": "Germany","continent": {"id": 3,"name": "Europe","iso": "EU"},"iso": "DE","iso_numeric": "276"},"city": "Frankfurt","sub_region": "Western Europe"}}}],"requested": "bing.com","finished": "true"}` )}, nil , true },
683683 }
684684 ctx := context .Background ()
685685 for name , tc := range testCases {
0 commit comments