2012-05-24 22:02:44 +04:00
|
|
|
/*
|
|
|
|
Copyright (c) 2012, Matt T. Proud
|
|
|
|
All rights reserved.
|
2012-05-20 01:59:25 +04:00
|
|
|
|
2012-05-24 22:02:44 +04:00
|
|
|
Use of this source code is governed by a BSD-style
|
|
|
|
license that can be found in the LICENSE file.
|
|
|
|
*/
|
2012-05-20 01:59:25 +04:00
|
|
|
|
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2013-01-18 19:29:47 +04:00
|
|
|
. "github.com/matttproud/gocheck"
|
2012-05-20 01:59:25 +04:00
|
|
|
)
|
|
|
|
|
2012-12-19 14:48:12 +04:00
|
|
|
func (s *S) TestGaugeCreate(c *C) {
|
2012-05-20 01:59:25 +04:00
|
|
|
m := GaugeMetric{value: 1.0}
|
|
|
|
|
|
|
|
c.Assert(m, Not(IsNil))
|
|
|
|
c.Check(m.Get(), Equals, 1.0)
|
|
|
|
}
|
|
|
|
|
2012-12-19 14:48:12 +04:00
|
|
|
func (s *S) TestGaugeString(c *C) {
|
2012-05-20 01:59:25 +04:00
|
|
|
m := GaugeMetric{value: 2.0}
|
2012-12-19 14:10:09 +04:00
|
|
|
c.Check(m.String(), Equals, "[GaugeMetric; value=2.000000]")
|
2012-05-20 01:59:25 +04:00
|
|
|
}
|
|
|
|
|
2012-12-19 14:48:12 +04:00
|
|
|
func (s *S) TestGaugeSet(c *C) {
|
2012-05-20 01:59:25 +04:00
|
|
|
m := GaugeMetric{value: -1.0}
|
|
|
|
|
|
|
|
m.Set(-99.0)
|
|
|
|
|
|
|
|
c.Check(m.Get(), Equals, -99.0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *S) TestGaugeMetricMarshallable(c *C) {
|
|
|
|
m := GaugeMetric{value: 1.0}
|
|
|
|
|
|
|
|
returned := m.Marshallable()
|
|
|
|
|
|
|
|
c.Assert(returned, Not(IsNil))
|
|
|
|
|
|
|
|
c.Check(returned, HasLen, 2)
|
|
|
|
c.Check(returned["value"], Equals, 1.0)
|
|
|
|
c.Check(returned["type"], Equals, "gauge")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *S) TestGaugeAsMetric(c *C) {
|
|
|
|
var metric Metric = &GaugeMetric{value: 1.0}
|
|
|
|
|
|
|
|
c.Assert(metric, Not(IsNil))
|
|
|
|
}
|