forked from cloudfoundry/go-cfclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events_test.go
53 lines (45 loc) · 1.22 KB
/
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
package cfclient
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestListEvents(t *testing.T) {
Convey("List Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/events", listEventsPage1Payload, "", 200, "", nil},
{"GET", "/v2/events-2", listEventsPage2Payload, "", 200, "page=2", nil},
}
setupMultiple(mocks, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
events, err := client.ListEvents()
So(err, ShouldBeNil)
So(len(events), ShouldEqual, 4)
So(events[0].GUID, ShouldEqual, "b8ede8e1-afc8-40a1-baae-236a0a77b27b")
So(events[0].Actor, ShouldEqual, "guid-008640fc-d316-4602-9251-c8d09bbdc750")
So(events[0].CreatedAt, ShouldEqual, "2016-06-08T16:41:23Z")
})
}
func TestTotalEvents(t *testing.T) {
Convey("Total Events", t, func() {
mocks := []MockRoute{
{"GET", "/v2/events", totalEventsPayload, "", 200, "", nil},
}
setupMultiple(mocks, t)
defer teardown()
c := &Config{
ApiAddress: server.URL,
Token: "foobar",
}
client, err := NewClient(c)
So(err, ShouldBeNil)
total, err := client.TotalEvents()
So(err, ShouldBeNil)
So(total, ShouldEqual, 4)
})
}