forked from skyline-ai/spotcrime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test.go
More file actions
61 lines (47 loc) · 1.2 KB
/
api_test.go
File metadata and controls
61 lines (47 loc) · 1.2 KB
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
package spotcrime
import "testing"
const (
testKey = "privatekeyforspotcrimepublicusers-commercialuse-877.410.1607"
testLat = 33.39657
testLon = -112.03422
httpProxyURL = "97.77.104.22"
// httpProxyURL = ""
)
func TestAPIWithProxy(t *testing.T) {
c, err := New(testKey)
if err != nil {
t.Fatalf("expected no error but got %s", err.Error())
}
resp, err := c.GetCrimes(&Request{
Lat: testLat,
Lon: testLon,
Proxy: httpProxyURL,
})
if err != nil {
t.Fatalf("expected no error but got %s", err.Error())
}
if resp == nil {
t.Fatal("expected not nil resp")
}
if len(resp.Results) == 0 {
t.Fatal("expected more than zero results in response")
}
if resp.Results[0].CDID == 0 {
t.Fatal("expected result CDID to be non empty")
}
if len(resp.Results[0].Date) == 0 {
t.Fatal("expected result Date to be non empty")
}
if resp.Results[0].Lat == 0 {
t.Fatal("expected result Lat to be non empty")
}
if len(resp.Results[0].Link) == 0 {
t.Fatal("expected result Link to be non empty")
}
if resp.Results[0].Lon == 0 {
t.Fatal("expected result Lon to be non empty")
}
if len(resp.Results[0].Type) == 0 {
t.Fatal("expected result Type to be non empty")
}
}