Skip to content

Commit

Permalink
Adding in some additional tests for improved coverage of mapquest geo…
Browse files Browse the repository at this point in the history
…coder
  • Loading branch information
kellydunn committed May 10, 2015
1 parent d4de4df commit 866871a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .#mapquest_geocoder.go
2 changes: 1 addition & 1 deletion mapquest_geocoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var MapquestAPIKey = ""
// This contains the base URL for the Mapquest Geocoder API.
var mapquestGeocodeURL = "http://open.mapquestapi.com/nominatim/v1"

func (g *MapQuestGeocoder) SetMapquestAPIKey(newAPIKey string) {
func SetMapquestAPIKey(newAPIKey string) {
MapquestAPIKey = newAPIKey
}

Expand Down
15 changes: 15 additions & 0 deletions mapquest_geocoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import (
"testing"
)

func TestSetMapquestAPIKey(t * testing.T) {
SetMapquestAPIKey("foo")
if MapquestAPIKey != "foo" {
t.Errorf("Mismatched value for MapQuestAPIKey. Expected: 'foo', Actual: %s", MapquestAPIKey)
}
}

func TestSetMapquestGeocodeURL(t *testing.T) {
SetMapquestGeocodeURL("foo")
if mapquestGeocodeURL != "foo" {
t.Errorf("Mismatched value for MapQuestGeocoeURL. Expected: 'foo', Actual: %s", mapquestGeocodeURL)
}
}

// Ensures that the Data Transfer Object used
// to get data from the Mapquest Geocoding API is well formed.
func TestMapQuestGeocodeFromRequest(t *testing.T) {
Expand All @@ -29,3 +43,4 @@ func TestMapQuestGeocodeFromRequest(t *testing.T) {
t.Error(fmt.Sprintf("Expected: [37.62181845, -122.383992092462], Got: [%s, %s]", res[0].Lat, res[0].Lng))
}
}

0 comments on commit 866871a

Please sign in to comment.