forked from kellydunn/golang-geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapquest_geocoder_test.go
40 lines (32 loc) · 1 KB
/
mapquest_geocoder_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
package geo
import (
"fmt"
"testing"
)
// TODO Test extracting LatLng from Mapquest Response
func TestMapQuestExtractLatLngFromRequest(t *testing.T) {
g := &MapQuestGeocoder{}
data, err := GetMockResponse("test/data/mapquest_geocode_success.json")
if err != nil {
t.Error("%v\n", err)
}
lat, lng, err := g.extractLatLngFromResponse(data)
if err != nil {
t.Error("%v\n", err)
}
if lat != 37.62181845 && lng != -122.383992092462 {
t.Error(fmt.Sprintf("Expected: [37.62181845, -122.383992092462], Got: [%f, %f]", lat, lng))
}
}
// TODO Test extracting LatLng from Mapquest Response when no results are returned
func TestMapQuestExtractLatLngFromRequestZeroResults(t *testing.T) {
g := &MapQuestGeocoder{}
data, err := GetMockResponse("test/data/mapquest_geocode_zero_results.json")
if err != nil {
t.Error("%v\n", err)
}
_, _, err = g.extractLatLngFromResponse(data)
if err != mapquestZeroResultsError {
t.Error(fmt.Sprintf("Expected error: %v, Got: %v"), mapquestZeroResultsError, err)
}
}