-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirststreet_test.go
78 lines (58 loc) · 1.8 KB
/
firststreet_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
package firststreet
import (
"errors"
"testing"
assert "github.com/stretchr/testify/require"
)
func TestNewBackend(t *testing.T) {
backend := NewBackend("abc123")
assert.Equal(t, "abc123", backend.Key)
}
func TestFSIDLookup(t *testing.T) {
fsid := "123456"
fsidLookup := &Lookup{
FSID: fsid,
}
assert.Equal(t, fsidLookup.FSID, fsid)
assert.True(t, fsidLookup.FSIDIsValid())
assert.False(t, fsidLookup.AddressIsValid())
assert.False(t, fsidLookup.LatLngIsValid())
lookupType, err := fsidLookup.LookupType()
assert.Nil(t, err)
assert.Equal(t, lookupType, FSIDLookup)
latlngString := fsidLookup.LatLngString("lat")
assert.Equal(t, latlngString, "")
}
func TestLatLngLookup(t *testing.T) {
latLngLookup := &Lookup{
Lat: 12.34,
Lng: 56.78,
}
assert.True(t, latLngLookup.LatLngIsValid())
assert.Equal(t, latLngLookup.LatLngString("lat"), "12.34")
assert.Equal(t, latLngLookup.LatLngString("lng"), "56.78")
assert.Equal(t, latLngLookup.LatLngString("gibberish"), "")
latLngLookupType, err := latLngLookup.LookupType()
assert.Nil(t, err)
assert.Equal(t, latLngLookupType, CoordinateLookup)
}
func TestAddressLookup(t *testing.T) {
addressLookup := &Lookup{
Address: "1234 Main St",
}
assert.True(t, addressLookup.AddressIsValid())
addressLookupType, err := addressLookup.LookupType()
assert.Nil(t, err)
assert.Equal(t, addressLookupType, AddressLookup)
}
func TestBadLookup(t *testing.T) {
badlookup := &Lookup{}
badType, err := badlookup.LookupType()
assert.Equal(t, badType, LookupType(""))
assert.Error(t, err, errors.New("Lookup type could not be determined: Expecting an FSID, Lat and Lng, or Address."))
}
// func TestIntegration(t *testing.T) {
// api := New("VpqgUoepulokFjdxZvE4iMjP8bTtN2PG")
// parcel, _ := api.Parcel.GetPropertyByID("100032470544")
// t.Log(parcel)
// }