コード例 #1
0
					_, err = page2.Next()
					Expect(err).To(HaveOccurred())
				})
			})
		})

		Describe("History", func() {
			It("returns a list of presence messages", func() {
				page, err := presence.History(nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(len(page.PresenceMessages())).To(Equal(len(testApp.Config.Channels[0].Presence)))
			})

			Context("with start and end time", func() {
				It("can return older items from a certain date given a start / end timestamp", func() {
					params := &ably.PaginateParams{
						ScopeParams: ably.ScopeParams{
							Start: ably.Timestamp(time.Now().Add(-24 * time.Hour)),
							End:   ably.Timestamp(time.Now()),
						},
					}
					page, err := presence.History(params)
					Expect(err).NotTo(HaveOccurred())
					Expect(len(page.PresenceMessages())).To(Equal(len(testApp.Config.Channels[0].Presence)))
				})
			})

		})
	})
})
コード例 #2
0
			]
		`

		BeforeEach(func() {
			err := json.NewDecoder(strings.NewReader(jsonStats)).Decode(&stats)
			Expect(err).NotTo(HaveOccurred())

			stats[0].IntervalID = proto.IntervalFormatFor(lastInterval.Add(-120*time.Minute), proto.StatGranularityMinute)
			stats[1].IntervalID = proto.IntervalFormatFor(lastInterval.Add(-60*time.Minute), proto.StatGranularityMinute)
			stats[2].IntervalID = proto.IntervalFormatFor(lastInterval.Add(-1*time.Minute), proto.StatGranularityMinute)

			res, err := client.Post("/stats", &stats, nil)
			Expect(err).NotTo(HaveOccurred())
			res.Body.Close()
		})

		It("parses stats from the rest api", func() {
			longAgo := lastInterval.Add(-120 * time.Minute)
			page, err := client.Stats(&ably.PaginateParams{
				Limit: 1,
				ScopeParams: ably.ScopeParams{
					Start: ably.Timestamp(longAgo),
					Unit:  proto.StatGranularityMinute,
				},
			})
			Expect(err).NotTo(HaveOccurred())
			Expect(page.Stats()[0].IntervalID).To(MatchRegexp("[0-9]+\\-[0-9]+\\-[0-9]+:[0-9]+:[0-9]+"))
		})
	})
})