-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathavailability_test.go
45 lines (38 loc) · 1.04 KB
/
availability_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
package ukpolice
import (
"context"
"fmt"
"net/http"
"reflect"
"testing"
)
func TestAvailabilityService_GetAvailabilityInfo(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc("/crimes-street-dates", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `
[
{
"date": "2015-06",
"stop-and-search": ["bedfordshire","cleveland","durham"]
},
{
"date": "2015-05",
"stop-and-search": ["bedfordshire","city-of-london","cleveland"]
}
]
`)
})
availabilityInfo, _, err := client.Availability.GetAvailabilityInfo(context.Background())
if err != nil {
t.Errorf("Availability.GetAvailabilityInfo returned error: '%+v'", err)
}
want := []AvailabilityInfo{
{"2015-06", []string{"bedfordshire", "cleveland", "durham"}},
{"2015-05", []string{"bedfordshire", "city-of-london", "cleveland"}},
}
if !reflect.DeepEqual(availabilityInfo, want) {
t.Errorf("Availability.GetAvailabilityInfo returned %v, want %v", availabilityInfo, want)
}
}