forked from cloudfoundry/go-cfclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
service_usage_events_test.go
61 lines (53 loc) · 1.79 KB
/
service_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 TestListServiceUsageEvents(t *testing.T) {
Convey("List Service Usage Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/service_usage_events", listServiceUsageEventsPayload, "", 200, "", nil},
{"GET", "/v2/service_usage_eventsPage2", listServiceUsageEventsPayloadPage2, "", 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)
serviceUsageEvents, err := client.ListServiceUsageEvents()
So(err, ShouldBeNil)
So(len(serviceUsageEvents), ShouldEqual, 4)
So(serviceUsageEvents[0].GUID, ShouldEqual, "985c09c5-bf5a-44eb-a260-41c532dc0f1d")
So(serviceUsageEvents[0].CreatedAt, ShouldEqual, "2016-06-08T16:41:39Z")
})
}
func TestListServiceUsageEventsByQuery(t *testing.T) {
Convey("List Service Usage Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/service_usage_events", listServiceUsageEventsPayload, "", 200, "results-per-page=2", nil},
{"GET", "/v2/service_usage_eventsPage2", listServiceUsageEventsPayloadPage2, "", 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",
},
}
serviceUsageEvents, err := client.ListServiceUsageEventsByQuery(query)
So(err, ShouldBeNil)
So(len(serviceUsageEvents), ShouldEqual, 4)
So(serviceUsageEvents[0].GUID, ShouldEqual, "985c09c5-bf5a-44eb-a260-41c532dc0f1d")
So(serviceUsageEvents[0].CreatedAt, ShouldEqual, "2016-06-08T16:41:39Z")
})
}