Esempio n. 1
0
		c := clients[0]
		Expect(c["address"]).To(Equal(ts.URL))
	})

	It("gets datapoints", func() {
		ts := time.Now()
		g.SaveDataPoint("kitchen temperature", quimby.DataPoint{Time: ts, Value: 23.2})
		time.Sleep(10 * time.Millisecond)
		ts2 := time.Now()
		g.SaveDataPoint("kitchen temperature", quimby.DataPoint{Time: ts2, Value: 23.4})
		points, err := g.GetDataPoints("kitchen temperature", ts, ts2, 0, false)
		Expect(err).To(BeNil())
		Expect(len(points)).To(Equal(2))

		p1 := points[0]
		Expect(p1.Time.Format(time.RFC3339)).To(Equal(ts.Format(time.RFC3339)))
		Expect(p1.Value).To(Equal(23.2))

		p2 := points[1]
		Expect(p2.Time.Format(time.RFC3339)).To(Equal(ts2.Format(time.RFC3339)))
		Expect(p2.Value).To(Equal(23.4))
	})

	It("gets binary datapoints", func() {
		ts := time.Now()
		g.SaveDataPoint("kitchen temperature", quimby.DataPoint{Time: ts, Value: 0.0})
		time.Sleep(10 * time.Millisecond)
		ts2 := time.Now()
		g.SaveDataPoint("kitchen temperature", quimby.DataPoint{Time: ts2, Value: 1.0})
		points, err := g.GetDataPoints("kitchen temperature", ts, ts2, 0, true)
		Expect(err).To(BeNil())