forked from mattevans/abode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabode_test.go
100 lines (88 loc) · 2.16 KB
/
abode_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package abode
import (
"reflect"
"testing"
"github.com/kylelemons/godebug/pretty"
. "github.com/onsi/gomega"
)
func TestExplodeUSAddress(t *testing.T) {
// Register the test.
RegisterTestingT(t)
// Init client
if client == nil {
err := initClient()
if err != nil {
t.Errorf("Unexpected error: %s", err)
}
}
line1 := "193 Rogers Avenue"
line2 := "Brooklyn"
state := "New York"
country := "United States"
countryCode := "US"
zip := "11216"
lat := 40.6706252
lng := -73.9530545
formatted := "193 Rogers Ave, Brooklyn, NY 11216, USA"
expected := &Address{
AddressLine1: &line1,
AddressLine2: &line2,
AddressCity: nil,
AddressState: &state,
AddressCountry: &country,
AddressCountryCode: &countryCode,
AddressZip: &zip,
AddressLat: &lat,
AddressLng: &lng,
FormattedAddress: &formatted,
}
address1 := "193 Rogers Ave, Brooklyn, New York"
result, err := Explode(address1)
if err != nil {
t.Errorf("Unexpected error: %s", err)
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Unexpected Results\n%s", pretty.Compare(result, expected))
}
}
func TestExplodeInternationalAddress(t *testing.T) {
// Register the test.
RegisterTestingT(t)
// Init client
if client == nil {
err := initClient()
if err != nil {
t.Errorf("Unexpected error: %s", err)
}
}
line1 := "1 4 Abercrombie Street"
line2 := "Howick"
city := "Auckland"
state := "Auckland"
country := "New Zealand"
countryCode := "NZ"
zip := "2014"
lat := -36.8991018
lng := 174.9338525
formatted := "1/4 Abercrombie Street, Howick, Auckland 2014, New Zealand"
expected := &Address{
AddressLine1: &line1,
AddressLine2: &line2,
AddressCity: &city,
AddressState: &state,
AddressCountry: &country,
AddressCountryCode: &countryCode,
AddressZip: &zip,
AddressLat: &lat,
AddressLng: &lng,
FormattedAddress: &formatted,
}
address1 := "1/4 Abercrombie Street, Auckland"
result, err := Explode(address1)
if err != nil {
t.Errorf("Unexpected error: %s", err)
}
if !reflect.DeepEqual(result, expected) {
t.Errorf("Unexpected Results\n%s", pretty.Compare(result, expected))
}
}