forked from cloudfoundry/go-cfclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_usage_events_test.go
61 lines (53 loc) · 1.7 KB
/
app_usage_events_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
package cfclient
import (
"net/url"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestListAppUsageEvents(t *testing.T) {
Convey("List App Usage Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/app_usage_events", listAppUsageEventsPayload, "", 200, "", nil},
{"GET", "/v2/app_usage_eventsPage2", listAppUsageEventsPayloadPage2, "", 200, "results-per-page=2&page=2", nil},
}
setupMultiple(mocks, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
appUsageEvents, err := client.ListAppUsageEvents()
So(err, ShouldBeNil)
So(len(appUsageEvents), ShouldEqual, 4)
So(appUsageEvents[0].GUID, ShouldEqual, "b32241a5-5508-4d42-893c-360e42a300b6")
So(appUsageEvents[0].CreatedAt, ShouldEqual, "2016-06-08T16:41:33Z")
})
}
func TestListAppUsageEventsByQuery(t *testing.T) {
Convey("List App Usage Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/app_usage_events", listAppUsageEventsPayload, "", 200, "results-per-page=2", nil},
{"GET", "/v2/app_usage_eventsPage2", listAppUsageEventsPayloadPage2, "", 200, "results-per-page=2&page=2", nil},
}
setupMultiple(mocks, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
var query = url.Values{
"results-per-page": []string{
"2",
},
}
appUsageEvents, err := client.ListAppUsageEventsByQuery(query)
So(err, ShouldBeNil)
So(len(appUsageEvents), ShouldEqual, 4)
So(appUsageEvents[0].GUID, ShouldEqual, "b32241a5-5508-4d42-893c-360e42a300b6")
So(appUsageEvents[0].CreatedAt, ShouldEqual, "2016-06-08T16:41:33Z")
})
}