client_golang/metrics/gauge_test.go

52 lines
976 B
Go
Raw Normal View History

/*
Copyright (c) 2012, Matt T. Proud
All rights reserved.
2012-05-20 01:59:25 +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 (
. "github.com/matttproud/gocheck"
2012-05-20 01:59:25 +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)
}
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
}
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))
}