(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func TestFindNearest(t *testing.T) { |
| 8 | t.Parallel() |
| 9 | |
| 10 | // Create map and lock faking in order to guarantee reproducability of faked data. |
| 11 | m := getDefaultTestMap() |
| 12 | fakeLock.Lock() |
| 13 | defer fakeLock.Unlock() |
| 14 | |
| 15 | for range 100 { |
| 16 | // Create a random destination address |
| 17 | ip4, loc4 := createGoodIP(true) |
| 18 | |
| 19 | nbPins, err := m.findNearestPins(loc4, nil, m.DefaultOptions(), DestinationHub, false) |
| 20 | if err != nil { |
| 21 | t.Error(err) |
| 22 | } else { |
| 23 | t.Logf("Pins near %s: %s", ip4, nbPins) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | for range 100 { |
| 28 | // Create a random destination address |
| 29 | ip6, loc6 := createGoodIP(true) |
| 30 | |
| 31 | nbPins, err := m.findNearestPins(nil, loc6, m.DefaultOptions(), DestinationHub, false) |
| 32 | if err != nil { |
| 33 | t.Error(err) |
| 34 | } else { |
| 35 | t.Logf("Pins near %s: %s", ip6, nbPins) |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /* |
| 41 | TODO: Find a way to quickly generate good geoip data on the fly, as we don't want to measure IP address generation, but only finding the nearest pins. |
nothing calls this directly
no test coverage detected